aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-06-29 09:56:37 +0100
committerwout <wout@impinc.co.uk>2013-06-29 09:56:37 +0100
commitb8f4400075126d9da64c5403333baa3c52048507 (patch)
treef49c70128dc3f666a4372a163fdbffdb0b7a409e /spec
parentfd9be25e66ce406c2c2081af8c8cb44357357639 (diff)
downloadsvg.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.html2
-rw-r--r--spec/spec/clip.js57
-rw-r--r--spec/spec/mask.js57
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