diff options
author | wout <wout@impinc.co.uk> | 2013-06-29 09:56:37 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-06-29 09:56:37 +0100 |
commit | b8f4400075126d9da64c5403333baa3c52048507 (patch) | |
tree | f49c70128dc3f666a4372a163fdbffdb0b7a409e /spec | |
parent | fd9be25e66ce406c2c2081af8c8cb44357357639 (diff) | |
download | svg.js-b8f4400075126d9da64c5403333baa3c52048507.tar.gz svg.js-b8f4400075126d9da64c5403333baa3c52048507.zip |
Fixed naming conflict in mask and clip modules, bumped to v0.22
Diffstat (limited to 'spec')
-rw-r--r-- | spec/index.html | 2 | ||||
-rw-r--r-- | spec/spec/clip.js | 57 | ||||
-rw-r--r-- | spec/spec/mask.js | 57 |
3 files changed, 116 insertions, 0 deletions
diff --git a/spec/index.html b/spec/index.html index 524bff7..d619acd 100644 --- a/spec/index.html +++ b/spec/index.html @@ -44,6 +44,8 @@ <script type="text/javascript" src="spec/doc.js"></script> <script type="text/javascript" src="spec/group.js"></script> <script type="text/javascript" src="spec/gradient.js"></script> +<script type="text/javascript" src="spec/mask.js"></script> +<script type="text/javascript" src="spec/clip.js"></script> <script type="text/javascript" src="spec/color.js"></script> <script type="text/javascript" src="spec/number.js"></script> diff --git a/spec/spec/clip.js b/spec/spec/clip.js new file mode 100644 index 0000000..ac3a147 --- /dev/null +++ b/spec/spec/clip.js @@ -0,0 +1,57 @@ +describe('ClipPath', function() { + var rect, circle + + beforeEach(function() { + rect = draw.rect(100,100) + circle = draw.circle(100).move(50, 50) + rect.clipWith(circle) + }) + + afterEach(function() { + draw.clear() + }) + + it('moves the masking element to a new clip node', function() { + expect(circle.parent instanceof SVG.Clip).toBe(true) + }) + + it('creates the clip node in the defs node', function() { + expect(circle.parent.parent).toBe(draw.defs()) + }) + + it('sets the "clip-path" attribute on the cliped element with the clip id', function() { + expect(rect.attr('clip-path')).toBe('url(#' + circle.parent.attr('id') + ')') + }) + + it('references the clip element in the masked element', function() { + expect(rect.clipper).toBe(circle.parent) + }) + + it('references the clipped element in the clipPath target list', function() { + expect(rect.clipper.targets.indexOf(rect) > -1).toBe(true) + }) + + it('unclips all clipped elements when being removed', function() { + rect.clipper.remove() + expect(rect.attr('clip-path')).toBe(undefined) + }) + + describe('unclip()', function() { + + it('clears the "clip-path" attribute on the clipped element', function() { + rect.unclip() + expect(rect.attr('clip-path')).toBe(undefined) + }) + + it('removes the reference to the clipping element', function() { + rect.unclip() + expect(rect.clipper).toBe(undefined) + }) + + it('returns the clipPath element', function() { + expect(rect.unclip()).toBe(rect) + }) + + }) + +})
\ No newline at end of file diff --git a/spec/spec/mask.js b/spec/spec/mask.js new file mode 100644 index 0000000..b8d8a10 --- /dev/null +++ b/spec/spec/mask.js @@ -0,0 +1,57 @@ +describe('Mask', function() { + var rect, circle + + beforeEach(function() { + rect = draw.rect(100,100) + circle = draw.circle(100).move(50, 50).fill('#fff') + rect.maskWith(circle) + }) + + afterEach(function() { + draw.clear() + }) + + it('moves the masking element to a new mask node', function() { + expect(circle.parent instanceof SVG.Mask).toBe(true) + }) + + it('creates the mask node in the defs node', function() { + expect(circle.parent.parent).toBe(draw.defs()) + }) + + it('sets the "mask" attribute on the masked element with the mask id', function() { + expect(rect.attr('mask')).toBe('url(#' + circle.parent.attr('id') + ')') + }) + + it('references the mask element in the masked element', function() { + expect(rect.masker).toBe(circle.parent) + }) + + it('references the masked element in the mask target list', function() { + expect(rect.masker.targets.indexOf(rect) > -1).toBe(true) + }) + + it('unmasks all masked elements when being removed', function() { + rect.masker.remove() + expect(rect.attr('mask')).toBe(undefined) + }) + + describe('unmask()', function() { + + it('clears the "mask" attribute on the masked element', function() { + rect.unmask() + expect(rect.attr('mask')).toBe(undefined) + }) + + it('removes the reference to the masking element', function() { + rect.unmask() + expect(rect.masker).toBe(undefined) + }) + + it('returns the element itslef', function() { + expect(rect.unmask()).toBe(rect) + }) + + }) + +})
\ No newline at end of file |