From 01f576d8eb04fd62ba288f6667a36e073dc9f0f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Sat, 25 Feb 2017 16:31:31 +0100 Subject: [PATCH] added test cases to increase code coverage --- spec/spec/bare.js | 11 ++++++++++- spec/spec/gradient.js | 16 +++++++++++----- 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('These are some words.') }) + 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('These are some words.') + }) }) -}) \ 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 + +}) -- 2.39.5