diff options
author | wout <wout@impinc.co.uk> | 2014-06-11 15:27:07 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-11 15:27:07 +0200 |
commit | e3a0f3a887a398a87356f63253830e1baf67823e (patch) | |
tree | d2b13c0dc0b4d40270cda7e1968860325d6c49b8 /spec | |
parent | 791f4368403571d5e824d91f3562c63baae356a8 (diff) | |
download | svg.js-e3a0f3a887a398a87356f63253830e1baf67823e.tar.gz svg.js-e3a0f3a887a398a87356f63253830e1baf67823e.zip |
Bumped to version 1.0.0-rc.7
Look at change log for full overview of changes.
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/index.html | 1 | ||||
-rwxr-xr-x | spec/spec/element.js | 8 | ||||
-rwxr-xr-x | spec/spec/pattern.js | 4 | ||||
-rw-r--r-- | spec/spec/regex.js | 27 | ||||
-rwxr-xr-x | spec/spec/svg.js | 10 | ||||
-rwxr-xr-x | spec/spec/text.js | 15 |
6 files changed, 52 insertions, 13 deletions
diff --git a/spec/index.html b/spec/index.html index 2044a3e..78d95d8 100755 --- a/spec/index.html +++ b/spec/index.html @@ -29,6 +29,7 @@ <!-- include spec files here... --> <script type="text/javascript" src="spec/svg.js"></script> +<script type="text/javascript" src="spec/regex.js"></script> <script type="text/javascript" src="spec/container.js"></script> <script type="text/javascript" src="spec/element.js"></script> <script type="text/javascript" src="spec/memory.js"></script> diff --git a/spec/spec/element.js b/spec/spec/element.js index 064c1e8..a0c7a2a 100755 --- a/spec/spec/element.js +++ b/spec/spec/element.js @@ -89,13 +89,13 @@ describe('Element', function() { describe('style()', function() { it('should set the style with key and value arguments', function() { var rect = draw.rect(100,100).style('cursor', 'crosshair') - expect(stripped(rect.node.getAttribute('style'))).toBe('cursor:crosshair;') + expect(stripped(rect.node.style.cssText)).toBe('cursor:crosshair;') }) it('should set multiple styles with an object as the first argument', function() { var rect = draw.rect(100,100).style({ cursor: 'help', display: 'block' }) - expect(stripped(rect.node.getAttribute('style'))).toMatch(/cursor:help;/) - expect(stripped(rect.node.getAttribute('style'))).toMatch(/display:block;/) - expect(stripped(rect.node.getAttribute('style')).length).toBe(('display:block;cursor:help;').length) + expect(stripped(rect.node.style.cssText)).toMatch(/cursor:help;/) + expect(stripped(rect.node.style.cssText)).toMatch(/display:block;/) + expect(stripped(rect.node.style.cssText).length).toBe(('display:block;cursor:help;').length) }) it('should get a style with a string key as the fists argument', function() { var rect = draw.rect(100,100).style({ cursor: 'progress', display: 'block' }) diff --git a/spec/spec/pattern.js b/spec/spec/pattern.js index b251801..4abdadc 100755 --- a/spec/spec/pattern.js +++ b/spec/spec/pattern.js @@ -37,6 +37,10 @@ describe('Pattern', function() { rect.attr('fill', pattern) expect(rect.attr('fill')).toBe('url(#' + pattern.attr('id') + ')') }) + it('is called when instance is passed in a fill() method', function() { + rect.fill(pattern) + expect(rect.attr('fill')).toBe('url(#' + pattern.attr('id') + ')') + }) }) describe('update()', function() { diff --git a/spec/spec/regex.js b/spec/spec/regex.js new file mode 100644 index 0000000..f64991a --- /dev/null +++ b/spec/spec/regex.js @@ -0,0 +1,27 @@ +describe('Regex', function() { + + describe('unit', function() { + it('is true with a positive unit value', function() { + expect(SVG.regex.unit.test('10%')).toBeTruthy() + }) + it('is true with a negative unit value', function() { + expect(SVG.regex.unit.test('-11%')).toBeTruthy() + }) + it('is false with a positive unit value', function() { + expect(SVG.regex.unit.test('NotAUnit')).toBeFalsy() + }) + }) + + describe('isEvent', function() { + it('is true with a namespaced and lowercase name', function() { + expect(SVG.regex.isEvent.test('my:event')).toBeTruthy() + }) + it('is true with a namespaced and camelCase name', function() { + expect(SVG.regex.isEvent.test('mt:fabulousEvent')).toBeTruthy() + }) + it('is false without a namespace', function() { + expect(SVG.regex.isEvent.test('idontlinkenamespaces')).toBeFalsy() + }) + }) + +})
\ No newline at end of file diff --git a/spec/spec/svg.js b/spec/spec/svg.js index 75f8a6d..843bb89 100755 --- a/spec/spec/svg.js +++ b/spec/spec/svg.js @@ -1,23 +1,23 @@ describe('SVG', function() { describe('()', function() { - var canvas, wrapper + var drawing, wrapper beforeEach(function() { wrapper = document.createElement('div') document.getElementsByTagName('body')[0].appendChild(wrapper) - canvas = SVG(wrapper) + drawing = SVG(wrapper) }) afterEach(function() { wrapper.parentNode.removeChild(wrapper) }) - it('creates a new svg canvas', function() { - expect(canvas.type).toBe('svg') + it('creates a new svg drawing', function() { + expect(drawing.type).toBe('svg') }) it('creates an instance of SVG.Doc', function() { - expect(canvas instanceof SVG.Doc).toBe(true) + expect(drawing instanceof SVG.Doc).toBe(true) }) }) diff --git a/spec/spec/text.js b/spec/spec/text.js index 6c4d9c6..2e373a4 100755 --- a/spec/spec/text.js +++ b/spec/spec/text.js @@ -33,15 +33,17 @@ describe('Text', function() { it('returns the value of y without an argument', function() { expect(text.y(0).y()).toBe(0) }) + it('returns the value of y when y is a percentual value', function() { + expect(text.y('45%').y()).toBe('45%') + }) it('sets the value of y with the first argument', function() { text.y(345) var box = text.bbox() expect(box.y).toBe(345) }) - it('sets the value of y based on the anchor with the first argument', function() { - text.y(345, true) - var box = text.bbox() - expect(box.y).toBe(345) + it('sets the value of y with a percent value', function() { + text.y('40%') + expect(text.node.getAttribute('y')).toBe('40%') }) }) @@ -112,6 +114,11 @@ describe('Text', function() { expect(text.node.childNodes[0].nodeType).toBe(1) expect(text.node.childNodes[0].childNodes[0].nodeValue).toBe('It is a bear!') }) + it('adds content in a nested tspan even with an empty string', function() { + text.text('') + expect(text.node.childNodes[0].nodeType).toBe(1) + expect(text.node.childNodes[0].childNodes[0].nodeValue).toBe('') + }) it('creates multiple lines with a newline separated string', function() { text.text('It is\nJUST\na bear!') expect(text.node.childNodes.length).toBe(3) |