summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-07-04 10:02:01 +0100
committerwout <wout@impinc.co.uk>2013-07-04 10:02:01 +0100
commit794f0defea662d94df8880e1e111e47de9f81621 (patch)
treed155c2e6ea694b53542e87fd0828f38c9e41ff9b /spec
parentdfa7123fb64bc13d2ce37b7f3e3be92db7f7fef8 (diff)
downloadsvg.js-794f0defea662d94df8880e1e111e47de9f81621.tar.gz
svg.js-794f0defea662d94df8880e1e111e47de9f81621.zip
Various IE9 and IE10 fixes
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/clip.js2
-rw-r--r--spec/spec/element.js54
-rw-r--r--spec/spec/ellipse.js2
-rw-r--r--spec/spec/group.js2
-rw-r--r--spec/spec/helper.js5
-rw-r--r--spec/spec/image.js2
-rw-r--r--spec/spec/line.js2
-rw-r--r--spec/spec/mask.js2
-rw-r--r--spec/spec/path.js2
-rw-r--r--spec/spec/polygon.js2
-rw-r--r--spec/spec/polyline.js2
-rw-r--r--spec/spec/rect.js2
-rw-r--r--spec/spec/text.js2
13 files changed, 45 insertions, 36 deletions
diff --git a/spec/spec/clip.js b/spec/spec/clip.js
index ac3a147..fb673f0 100644
--- a/spec/spec/clip.js
+++ b/spec/spec/clip.js
@@ -20,7 +20,7 @@ describe('ClipPath', function() {
})
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') + ')')
+ expect(rect.attr('clip-path')).toBe('url("#' + circle.parent.attr('id') + '")')
})
it('references the clip element in the masked element', function() {
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 6deeffb..cbe4088 100644
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -57,11 +57,11 @@ describe('Element', function() {
})
it('gets the "style" attribute as a string', function() {
rect.style('cursor', 'pointer')
- expect(rect.attr('style')).toBe('cursor:pointer;')
+ expect(stripped(rect.attr('style'))).toBe('cursor:pointer;')
})
it('redirects to the style() method when setting a style string', function() {
rect.attr('style', 'cursor:move;')
- expect(rect.node.getAttribute('style')).toBe('cursor:move;')
+ expect(stripped(rect.node.getAttribute('style'))).toBe('cursor:move;')
})
it('should remove style attribute on node if the style is empty', function() {
rect.style('style', '')
@@ -88,11 +88,13 @@ describe('Element', function() {
describe('style()', function() {
it('should set the style with key and value arguments', function() {
var rect = draw.rect(100,100).style('cursor', 'crosshair')
- expect(rect.node.getAttribute('style')).toBe('cursor:crosshair;')
+ expect(stripped(rect.node.getAttribute('style'))).toBe('cursor:crosshair;')
})
it('should set multiple styles with an object as the first argument', function() {
var rect = draw.rect(100,100).style({ cursor: 'help', display: 'block' })
- expect(rect.node.getAttribute('style')).toBe('cursor:help;display:block;')
+ expect(stripped(rect.node.getAttribute('style'))).toMatch(/cursor:help;/)
+ expect(stripped(rect.node.getAttribute('style'))).toMatch(/display:block;/)
+ expect(stripped(rect.node.getAttribute('style')).length).toBe(('display:block;cursor:help;').length)
})
it('should get a style with a string key as the fists argument', function() {
var rect = draw.rect(100,100).style({ cursor: 'progress', display: 'block' })
@@ -100,15 +102,17 @@ describe('Element', function() {
})
it('should get a style with a string key as the fists argument', function() {
var rect = draw.rect(100,100).style({ cursor: 's-resize', display: 'none' })
- expect(rect.style()).toBe('cursor:s-resize;display:none;')
+ expect(stripped(rect.style())).toMatch(/display:none;/)
+ expect(stripped(rect.style())).toMatch(/cursor:s-resize;/)
+ expect(stripped(rect.style()).length).toBe(('cursor:s-resize;display:none;').length)
})
it('should remove a style if the value is an empty string', function() {
var rect = draw.rect(100,100).style({ cursor: 'n-resize', display: '' })
- expect(rect.style()).toBe('cursor:n-resize;')
+ expect(stripped(rect.style())).toBe('cursor:n-resize;')
})
it('should remove a style if the value explicitly set to null', function() {
var rect = draw.rect(100,100).style('cursor', 'w-resize')
- expect(rect.style()).toBe('cursor:w-resize;')
+ expect(stripped(rect.style())).toBe('cursor:w-resize;')
rect.style('cursor', null)
expect(rect.style()).toBe('')
})
@@ -121,15 +125,15 @@ describe('Element', function() {
})
it('should set the translation of and element', function() {
var rect = draw.rect(100,100).transform({ x: 10, y: 10 })
- expect(rect.node.getAttribute('transform')).toBe('translate(10,10)')
+ expect(rect.node.getAttribute('transform')).toBe('translate(10 10)')
})
it('should set the scaleX of and element', function() {
var rect = draw.rect(100,100).transform({ scaleX: 0.1 })
- expect(rect.node.getAttribute('transform')).toBe('scale(0.1,1)')
+ expect(rect.node.getAttribute('transform')).toBe('scale(0.1 1)')
})
it('should set the scaleY of and element', function() {
var rect = draw.rect(100,100).transform({ scaleY: 10 })
- expect(rect.node.getAttribute('transform')).toBe('scale(1,10)')
+ expect(rect.node.getAttribute('transform')).toBe('scale(1 10)')
})
it('should set the skewX of and element', function() {
var rect = draw.rect(100,100).transform({ skewX: 0.1 })
@@ -141,15 +145,15 @@ describe('Element', function() {
})
it('should rotate the element around its centre if no rotation point is given', function() {
var rect = draw.rect(100,100).transform({ rotation: 45 })
- expect(rect.node.getAttribute('transform')).toBe('rotate(45,50,50)')
+ expect(rect.node.getAttribute('transform')).toBe('rotate(45 50 50)')
})
it('should rotate the element around the given rotation point', function() {
var rect = draw.rect(100,100).transform({ rotation: 55, cx: 80, cy:2 })
- expect(rect.node.getAttribute('transform')).toBe('rotate(55,80,2)')
+ expect(rect.node.getAttribute('transform')).toBe('rotate(55 80 2)')
})
it('should transform element using a matrix', function() {
var rect = draw.rect(100,100).transform({ a: 0.5, c: 0.5 })
- expect(rect.node.getAttribute('transform')).toBe('matrix(0.5,0,0.5,1,0,0)')
+ expect(rect.node.getAttribute('transform')).toBe('matrix(0.5 0 0.5 1 0 0)')
})
})
@@ -197,22 +201,22 @@ describe('Element', function() {
it('returns the correct rectangular box', function() {
var rect = draw.size(200,150).viewbox(0,0,200,150).rect(105,210).move(2,12)
var box = rect.rbox()
- expect(box.x).toBe(2)
- expect(box.y).toBe(12)
- expect(box.cx).toBe(54.5)
- expect(box.cy).toBe(117)
- expect(box.width).toBe(105)
- expect(box.height).toBe(210)
+ expect(approximately(box.x)).toBe(approximately(2))
+ expect(approximately(box.y)).toBe(approximately(12))
+ expect(approximately(box.cx)).toBe(approximately(54).5)
+ expect(approximately(box.cy)).toBe(approximately(117))
+ expect(approximately(box.width)).toBe(approximately(105))
+ expect(approximately(box.height)).toBe(approximately(210))
})
it('returns the correct rectangular box within a viewbox', function() {
var rect = draw.size(200,150).viewbox(0,0,100,75).rect(105,210).move(2,12)
var box = rect.rbox()
- expect(box.x).toBe(1)
- expect(box.y).toBe(6)
- expect(box.cx).toBe(27.25)
- expect(box.cy).toBe(58.5)
- expect(box.width).toBe(52.5)
- expect(box.height).toBe(105)
+ expect(approximately(box.x)).toBe(approximately(1))
+ expect(approximately(box.y)).toBe(approximately(6))
+ expect(approximately(box.cx)).toBe(approximately(27.25))
+ expect(approximately(box.cy)).toBe(approximately(58.5))
+ expect(approximately(box.width)).toBe(approximately(52.5))
+ expect(approximately(box.height)).toBe(approximately(105))
})
})
diff --git a/spec/spec/ellipse.js b/spec/spec/ellipse.js
index cd3e0e5..507ec7a 100644
--- a/spec/spec/ellipse.js
+++ b/spec/spec/ellipse.js
@@ -97,7 +97,7 @@ describe('Ellipse', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
ellipse.transform({ x: 12, y: 12 })
- expect(ellipse.node.getAttribute('transform')).toBe('translate(12,12)')
+ expect(ellipse.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/group.js b/spec/spec/group.js
index f0404fd..64d0463 100644
--- a/spec/spec/group.js
+++ b/spec/spec/group.js
@@ -57,7 +57,7 @@ describe('Group', function() {
describe('move()', function() {
it('sets the x and y position', function() {
group.move(123,456)
- expect(group.node.getAttribute('transform')).toBe('translate(123,456)')
+ expect(group.node.getAttribute('transform')).toBe('translate(123 456)')
})
})
diff --git a/spec/spec/helper.js b/spec/spec/helper.js
index f6cebaa..7394754 100644
--- a/spec/spec/helper.js
+++ b/spec/spec/helper.js
@@ -18,4 +18,9 @@ function approximately(number, precision) {
precision = precision == null ? 2.5 : precision
return Math.round(number / precision) * precision
+}
+
+/* strip spaces from result */
+function stripped(string) {
+ return string.replace(/\s+/g, '')
} \ No newline at end of file
diff --git a/spec/spec/image.js b/spec/spec/image.js
index 544a937..dec462b 100644
--- a/spec/spec/image.js
+++ b/spec/spec/image.js
@@ -96,7 +96,7 @@ describe('Image', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
image.transform({ x: 12, y: 12 })
- expect(image.node.getAttribute('transform')).toBe('translate(12,12)')
+ expect(image.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/line.js b/spec/spec/line.js
index f70caba..348201c 100644
--- a/spec/spec/line.js
+++ b/spec/spec/line.js
@@ -102,7 +102,7 @@ describe('Line', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
line.transform({ x: 12, y: 12 })
- expect(line.node.getAttribute('transform')).toBe('translate(12,12)')
+ expect(line.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/mask.js b/spec/spec/mask.js
index b8d8a10..a13d842 100644
--- a/spec/spec/mask.js
+++ b/spec/spec/mask.js
@@ -20,7 +20,7 @@ describe('Mask', function() {
})
it('sets the "mask" attribute on the masked element with the mask id', function() {
- expect(rect.attr('mask')).toBe('url(#' + circle.parent.attr('id') + ')')
+ expect(rect.attr('mask')).toBe('url("#' + circle.parent.attr('id') + '")')
})
it('references the mask element in the masked element', function() {
diff --git a/spec/spec/path.js b/spec/spec/path.js
index bb312ad..77ef77c 100644
--- a/spec/spec/path.js
+++ b/spec/spec/path.js
@@ -104,7 +104,7 @@ describe('Path', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
path.transform({ x: 12, y: 12 })
- expect(path.node.getAttribute('transform')).toBe('translate(12,12) translate(0,0)')
+ expect(path.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/polygon.js b/spec/spec/polygon.js
index 93b4e38..32d752e 100644
--- a/spec/spec/polygon.js
+++ b/spec/spec/polygon.js
@@ -98,7 +98,7 @@ describe('Polygon', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
polygon.transform({ x: 12, y: 12 })
- expect(polygon.node.getAttribute('transform')).toBe('translate(12,12) translate(0,0)')
+ expect(polygon.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/polyline.js b/spec/spec/polyline.js
index f959795..e3f2652 100644
--- a/spec/spec/polyline.js
+++ b/spec/spec/polyline.js
@@ -98,7 +98,7 @@ describe('Polyline', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
polyline.transform({ x: 12, y: 12 })
- expect(polyline.node.getAttribute('transform')).toBe('translate(12,12) translate(0,0)')
+ expect(polyline.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/rect.js b/spec/spec/rect.js
index 61b9363..2ebab04 100644
--- a/spec/spec/rect.js
+++ b/spec/spec/rect.js
@@ -96,7 +96,7 @@ describe('Rect', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
rect.transform({ x: 12, y: 12 })
- expect(rect.node.getAttribute('transform')).toBe('translate(12,12)')
+ expect(rect.node.getAttribute('transform')).toBe('translate(12 12)')
})
})
diff --git a/spec/spec/text.js b/spec/spec/text.js
index 18acec6..5ec9640 100644
--- a/spec/spec/text.js
+++ b/spec/spec/text.js
@@ -106,7 +106,7 @@ describe('Text', function() {
describe('translate()', function() {
it('should set the translation of an element', function() {
text.transform({ x: 12, y: 12 })
- expect(text.node.getAttribute('transform')).toBe('translate(12,12)')
+ expect(text.node.getAttribute('transform')).toBe('translate(12 12)')
})
})