diff options
author | wout <wout@impinc.co.uk> | 2014-02-05 00:06:36 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-02-05 00:06:36 +0100 |
commit | 9995944cb253ba93441e2d65cef415daa3541a52 (patch) | |
tree | 9d69d943841bec9a25039ee417d58a3125249723 /spec | |
parent | 43fd91ccce8f9bce60ed7c566e32152be42f9774 (diff) | |
download | svg.js-9995944cb253ba93441e2d65cef415daa3541a52.tar.gz svg.js-9995944cb253ba93441e2d65cef415daa3541a52.zip |
Added loader on SVG.Image and included svg.pattern.js to the core
Diffstat (limited to 'spec')
-rw-r--r-- | spec/index.html | 1 | ||||
-rw-r--r-- | spec/spec/gradient.js | 7 | ||||
-rw-r--r-- | spec/spec/pattern.js | 59 |
3 files changed, 66 insertions, 1 deletions
diff --git a/spec/index.html b/spec/index.html index a702289..2044a3e 100644 --- a/spec/index.html +++ b/spec/index.html @@ -47,6 +47,7 @@ <script type="text/javascript" src="spec/group.js"></script> <script type="text/javascript" src="spec/set.js"></script> <script type="text/javascript" src="spec/gradient.js"></script> +<script type="text/javascript" src="spec/pattern.js"></script> <script type="text/javascript" src="spec/use.js"></script> <script type="text/javascript" src="spec/mask.js"></script> <script type="text/javascript" src="spec/clip.js"></script> diff --git a/spec/spec/gradient.js b/spec/spec/gradient.js index 7072164..a0e4d98 100644 --- a/spec/spec/gradient.js +++ b/spec/spec/gradient.js @@ -17,6 +17,11 @@ describe('Gradient', function() { it('is an instance of SVG.Gradient', function() { expect(gradient instanceof SVG.Gradient).toBe(true) }) + + it('allows creation of a new gradient without block', 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() { @@ -77,7 +82,7 @@ describe('Gradient', function() { }) expect(gradient.children().length).toBe(2) }) - + }) describe('get()', function() { diff --git a/spec/spec/pattern.js b/spec/spec/pattern.js new file mode 100644 index 0000000..b251801 --- /dev/null +++ b/spec/spec/pattern.js @@ -0,0 +1,59 @@ +describe('Pattern', function() { + var rect, pattern + + beforeEach(function() { + rect = draw.rect(100,100) + pattern = draw.pattern(20, 30, function(add) { + add.rect(10,10).move(10,10) + add.circle(30) + }) + }) + + afterEach(function() { + rect.remove() + pattern.remove() + }) + + it('is an instance of SVG.Pattern', function() { + expect(pattern instanceof SVG.Pattern).toBe(true) + }) + + it('allows creation of a new gradient without block', 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('toString()', function() { + it('returns the id of the pattern wrapped in url()', function() { + expect(pattern + '').toBe('url(#' + pattern.attr('id') + ')') + }) + it('is called when instance is passed as an attribute value', function() { + rect.attr('fill', pattern) + expect(rect.attr('fill')).toBe('url(#' + pattern.attr('id') + ')') + }) + }) + + describe('update()', function() { + + it('removes all existing children first', function() { + pattern = draw.pattern(30, 30, function(add) { + add.rect(10,10).move(10,10) + add.circle(30) + }) + expect(pattern.children().length).toBe(2) + pattern.update(function(add) { + add.rect(10,10).move(10,10) + add.circle(30) + }) + expect(pattern.children().length).toBe(2) + }) + + }) + +})
\ No newline at end of file |