diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-25 16:31:31 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-25 16:31:31 +0100 |
commit | 01f576d8eb04fd62ba288f6667a36e073dc9f0f9 (patch) | |
tree | 6a1e57b39447ac15d3008c29d2ba2ad5845418fa /spec | |
parent | 6d2c2bdc36a3b78012da55add9d9bf519ed3509f (diff) | |
download | svg.js-01f576d8eb04fd62ba288f6667a36e073dc9f0f9.tar.gz svg.js-01f576d8eb04fd62ba288f6667a36e073dc9f0f9.zip |
added test cases to increase code coverage
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/bare.js | 11 | ||||
-rw-r--r-- | spec/spec/gradient.js | 16 | ||||
-rw-r--r-- | spec/spec/pattern.js | 14 |
3 files changed, 31 insertions, 10 deletions
diff --git a/spec/spec/bare.js b/spec/spec/bare.js index 185a965..9dbb8c2 100644 --- a/spec/spec/bare.js +++ b/spec/spec/bare.js @@ -13,6 +13,10 @@ describe('Bare', function() { it('creates element in called parent', function() { expect(element.parent()).toBe(draw) }) + it('inherits from given parent', function() { + expect(draw.element('g', SVG.Container).rect).toBeTruthy() + expect(draw.element('g', SVG.Container).group).toBeTruthy() + }) }) describe('words()', function() { @@ -20,5 +24,10 @@ describe('Bare', function() { var element = draw.element('title').words('These are some words.').id(null) expect(element.svg()).toBe('<title>These are some words.</title>') }) + it('removes all nodes before adding words', function() { + var element = draw.element('title').words('These are some words.').id(null) + element.words('These are some words.') + expect(element.svg()).toBe('<title>These are some words.</title>') + }) }) -})
\ No newline at end of file +}) diff --git a/spec/spec/gradient.js b/spec/spec/gradient.js index 25eeff3..e0b061a 100644 --- a/spec/spec/gradient.js +++ b/spec/spec/gradient.js @@ -13,7 +13,7 @@ describe('Gradient', function() { rect.remove() gradient.remove() }) - + it('is an instance of SVG.Gradient', function() { expect(gradient instanceof SVG.Gradient).toBe(true) }) @@ -22,13 +22,19 @@ describe('Gradient', function() { gradient = draw.gradient('linear') expect(gradient.children().length).toBe(0) }) - + describe('fill()', function() { it('returns the id of the gradient wrapped in url()', function() { expect(gradient.fill()).toBe('url(#' + gradient.attr('id') + ')') }) }) + describe('attr()', function() { + it('will catch transform attribues and convert them to gradientTransform', function() { + expect(gradient.translate(100,100).attr('gradientTransform')).toBe('matrix(1,0,0,1,100,100)') + }) + }) + describe('toString()', function() { it('returns the id of the gradient wrapped in url()', function() { expect(gradient + '').toBe('url(#' + gradient.attr('id') + ')') @@ -95,7 +101,7 @@ describe('Gradient', function() { expect(s2.attr('stop-color')).toBe('#ffffff') expect(s2.attr('stop-opacity')).toBe(0.5) }) - + }) describe('get()', function() { @@ -111,5 +117,5 @@ describe('Gradient', function() { }) }) - -})
\ No newline at end of file + +}) diff --git a/spec/spec/pattern.js b/spec/spec/pattern.js index 4abdadc..e12d11e 100644 --- a/spec/spec/pattern.js +++ b/spec/spec/pattern.js @@ -13,7 +13,7 @@ describe('Pattern', function() { rect.remove() pattern.remove() }) - + it('is an instance of SVG.Pattern', function() { expect(pattern instanceof SVG.Pattern).toBe(true) }) @@ -22,13 +22,19 @@ describe('Pattern', function() { pattern = draw.pattern(10,30) expect(pattern.children().length).toBe(0) }) - + describe('fill()', function() { it('returns the id of the pattern wrapped in url()', function() { expect(pattern.fill()).toBe('url(#' + pattern.attr('id') + ')') }) }) + describe('attr()', function() { + it('will catch transform attribues and convert them to patternTransform', function() { + expect(pattern.translate(100,100).attr('patternTransform')).toBe('matrix(1,0,0,1,100,100)') + }) + }) + describe('toString()', function() { it('returns the id of the pattern wrapped in url()', function() { expect(pattern + '').toBe('url(#' + pattern.attr('id') + ')') @@ -59,5 +65,5 @@ describe('Pattern', function() { }) }) - -})
\ No newline at end of file + +}) |