summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-08-01 13:32:56 +0100
committerwout <wout@impinc.co.uk>2013-08-01 13:32:56 +0100
commiteecebe3cdfdae38f4e0613807e7fd64359cb84fd (patch)
tree64ecf24398abedbf4ba657fd6b5905652b83129e /spec
parent21d6c0b30a530ce7746f789921c7135079f43338 (diff)
downloadsvg.js-eecebe3cdfdae38f4e0613807e7fd64359cb84fd.tar.gz
svg.js-eecebe3cdfdae38f4e0613807e7fd64359cb84fd.zip
Added animatible poly's, bumped to v0.31
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/array.js13
-rw-r--r--spec/spec/line.js49
-rw-r--r--spec/spec/number.js4
-rw-r--r--spec/spec/polygon.js14
-rw-r--r--spec/spec/polyline.js14
5 files changed, 57 insertions, 37 deletions
diff --git a/spec/spec/array.js b/spec/spec/array.js
index 2a6922d..375326c 100644
--- a/spec/spec/array.js
+++ b/spec/spec/array.js
@@ -9,8 +9,19 @@ describe('Array', function () {
expect(array + '').toBe('0.343 0.669 0.119 0 0 0.249 -0.626 0.13 0 0 0.172 0.334 0.111 0 0 0 0 0 1 0')
})
+})
+
+
+describe('PointArray', function () {
+
+ it('parses a string to a point array', function() {
+ var array = new SVG.PointArray('0,1 -.05,7.95 1000.0001,-200.222')
+
+ expect(array.valueOf()).toEqual([[0, 1], [-0.05, 7.95], [1000.0001, -200.222]])
+ })
+
it('parses a points array correctly to string', function() {
- var array = new SVG.Array([[0,.15], [-100,-3.141592654], [50,100]])
+ var array = new SVG.PointArray([[0,.15], [-100,-3.141592654], [50,100]])
expect(array + '').toBe('0,0.15 -100,-3.141592654 50,100')
})
diff --git a/spec/spec/line.js b/spec/spec/line.js
index 348201c..91874b9 100644
--- a/spec/spec/line.js
+++ b/spec/spec/line.js
@@ -56,10 +56,11 @@ describe('Line', function() {
describe('move()', function() {
it('should set the x and y position', function() {
line.move(123,456)
- expect(line.node.getAttribute('x1')).toBe('123')
- expect(line.node.getAttribute('y1')).toBe('556')
- expect(line.node.getAttribute('x2')).toBe('223')
- expect(line.node.getAttribute('y2')).toBe('456')
+ var box = line.bbox()
+ expect(box.x).toBe(123)
+ expect(box.y + box.height).toBe(556)
+ expect(box.x + box.width).toBe(223)
+ expect(box.y).toBe(456)
})
})
@@ -67,35 +68,38 @@ describe('Line', function() {
it('should set the cx and cy position', function() {
line.center(321,567)
var box = line.bbox()
- expect(line.node.getAttribute('x1')).toBe('271')
- expect(line.node.getAttribute('y1')).toBe('617')
- expect(line.node.getAttribute('x2')).toBe('371')
- expect(line.node.getAttribute('y2')).toBe('517')
+ expect(box.x).toBe(271)
+ expect(box.y + box.height).toBe(617)
+ expect(box.x + box.width).toBe(371)
+ expect(box.y).toBe(517)
})
})
describe('size()', function() {
it('should define the width and height of the element', function() {
line.size(987,654)
- expect(line.node.getAttribute('x1')).toBe('0')
- expect(line.node.getAttribute('y1')).toBe('654')
- expect(line.node.getAttribute('x2')).toBe('987')
- expect(line.node.getAttribute('y2')).toBe('0')
+ var box = line.bbox()
+ expect(box.x).toBe(0)
+ expect(box.y + box.height).toBe(654)
+ expect(box.x + box.width).toBe(987)
+ expect(box.y).toBe(0)
})
})
describe('scale()', function() {
it('should scale the element universally with one argument', function() {
- var box = line.scale(2).bbox()
+ var box1 = line.bbox()
+ , box2 = line.scale(2).bbox()
- expect(box.width).toBe((line.attr('x2') - line.attr('x1')) * 2)
- expect(box.height).toBe((line.attr('y1') - line.attr('y2')) * 2)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 2)
})
it('should scale the element over individual x and y axes with two arguments', function() {
- var box = line.scale(2, 3.5).bbox()
+ var box1 = line.bbox()
+ , box2 = line.scale(2,3.5).bbox()
- expect(box.width).toBe((line.attr('x2') - line.attr('x1')) * 2)
- expect(box.height).toBe((line.attr('y1') - line.attr('y2')) * 3.5)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 3.5)
})
})
@@ -109,10 +113,11 @@ describe('Line', function() {
describe('plot()', function() {
it('should update the start and end points', function() {
line.plot(100,200,300,400)
- expect(line.node.getAttribute('x1')).toBe('100')
- expect(line.node.getAttribute('y1')).toBe('200')
- expect(line.node.getAttribute('x2')).toBe('300')
- expect(line.node.getAttribute('y2')).toBe('400')
+ var box = line.bbox()
+ expect(box.x).toBe(100)
+ expect(box.y).toBe(200)
+ expect(box.x + box.width).toBe(300)
+ expect(box.y + box.height).toBe(400)
})
})
diff --git a/spec/spec/number.js b/spec/spec/number.js
index e6261d3..1638671 100644
--- a/spec/spec/number.js
+++ b/spec/spec/number.js
@@ -34,11 +34,11 @@ describe('Number', function() {
})
it('falls back to maximum value if given number is positive infinite', function() {
number = new SVG.Number(1.7976931348623157E+10308)
- expect(number.value).toBe(Number.MAX_VALUE)
+ expect(number.value).toBe(3.4e+38)
})
it('falls back to minimum value if given number is negative infinite', function() {
number = new SVG.Number(-1.7976931348623157E+10308)
- expect(number.value).toBe(Number.MIN_VALUE)
+ expect(number.value).toBe(-3.4e+38)
})
})
diff --git a/spec/spec/polygon.js b/spec/spec/polygon.js
index 32d752e..f0f131f 100644
--- a/spec/spec/polygon.js
+++ b/spec/spec/polygon.js
@@ -82,16 +82,18 @@ describe('Polygon', function() {
describe('scale()', function() {
it('should scale the element universally with one argument', function() {
- var box = polygon.scale(2).bbox()
+ var box1 = polygon.bbox()
+ , box2 = polygon.scale(2).bbox()
- expect(box.width).toBe(polygon._offset.width * 2)
- expect(box.height).toBe(polygon._offset.height * 2)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 2)
})
it('should scale the element over individual x and y axes with two arguments', function() {
- var box = polygon.scale(2, 3.5).bbox()
+ var box1 = polygon.bbox()
+ , box2 = polygon.scale(2, 3.5).bbox()
- expect(box.width).toBe(polygon._offset.width * 2)
- expect(box.height).toBe(polygon._offset.height * 3.5)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 3.5)
})
})
diff --git a/spec/spec/polyline.js b/spec/spec/polyline.js
index e3f2652..c8dcc00 100644
--- a/spec/spec/polyline.js
+++ b/spec/spec/polyline.js
@@ -82,16 +82,18 @@ describe('Polyline', function() {
describe('scale()', function() {
it('should scale the element universally with one argument', function() {
- var box = polyline.scale(2).bbox()
+ var box1 = polyline.bbox()
+ , box2 = polyline.scale(2).bbox()
- expect(box.width).toBe(polyline._offset.width * 2)
- expect(box.height).toBe(polyline._offset.height * 2)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 2)
})
it('should scale the element over individual x and y axes with two arguments', function() {
- var box = polyline.scale(2, 3.5).bbox()
+ var box1 = polyline.bbox()
+ , box2 = polyline.scale(2, 3.5).bbox()
- expect(box.width).toBe(polyline._offset.width * 2)
- expect(box.height).toBe(polyline._offset.height * 3.5)
+ expect(box2.width).toBe(box1.width * 2)
+ expect(box2.height).toBe(box1.height * 3.5)
})
})