diff options
author | Saivan <savian@me.com> | 2018-03-02 19:54:01 +1100 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-03-02 19:54:01 +1100 |
commit | e0964238b0a68c310b94dc26f54951d77503d0c8 (patch) | |
tree | 0d01d483f1e61561686bd2ce6adcaa337cf598fd /spec | |
parent | 1cba40f6a039d8ff0b87043b5cb9e1f28b3655ee (diff) | |
download | svg.js-e0964238b0a68c310b94dc26f54951d77503d0c8.tar.gz svg.js-e0964238b0a68c310b94dc26f54951d77503d0c8.zip |
Fixed a few more specifications regarding the new transforms
Diffstat (limited to 'spec')
-rw-r--r-- | spec/SpecRunner.html | 10 | ||||
-rw-r--r-- | spec/spec/boxes.js | 6 | ||||
-rw-r--r-- | spec/spec/circle.js | 28 | ||||
-rw-r--r-- | spec/spec/doc.js | 6 | ||||
-rw-r--r-- | spec/spec/element.js | 14 | ||||
-rw-r--r-- | spec/spec/ellipse.js | 36 | ||||
-rw-r--r-- | spec/spec/matrix.js | 23 |
7 files changed, 42 insertions, 81 deletions
diff --git a/spec/SpecRunner.html b/spec/SpecRunner.html index 62e9121..4e4a252 100644 --- a/spec/SpecRunner.html +++ b/spec/SpecRunner.html @@ -52,7 +52,7 @@ <!-- include spec files here... --> - <!-- <script src="spec/adopter.js"></script> + <script src="spec/adopter.js"></script> <script src="spec/arrange.js"></script> <script src="spec/array.js"></script> <script src="spec/bare.js"></script> @@ -63,13 +63,13 @@ <script src="spec/container.js"></script> <script src="spec/defs.js"></script> <script src="spec/doc.js"></script> - <script src="spec/easing.js"></script> --> + <script src="spec/easing.js"></script> <script src="spec/element.js"></script> - <!-- <script src="spec/ellipse.js"></script> + <script src="spec/ellipse.js"></script> <script src="spec/event.js"></script> - <script src="spec/fx.js"></script> + <!-- <script src="spec/fx.js"></script> --> <script src="spec/gradient.js"></script> - <script src="spec/group.js"></script>--> + <script src="spec/group.js"></script> <script src="spec/helper.js"></script> <!--<script src="spec/hyperlink.js"></script> <script src="spec/image.js"></script> diff --git a/spec/spec/boxes.js b/spec/spec/boxes.js index 9e33c60..b5822c8 100644 --- a/spec/spec/boxes.js +++ b/spec/spec/boxes.js @@ -269,9 +269,3 @@ describe('Boxes', function() { }) }) - - - - - - diff --git a/spec/spec/circle.js b/spec/spec/circle.js index fc66e0c..c0f0936 100644 --- a/spec/spec/circle.js +++ b/spec/spec/circle.js @@ -1,14 +1,14 @@ describe('Circle', function() { var circle - + beforeEach(function() { circle = draw.circle(240) }) - + afterEach(function() { draw.clear() }) - + describe('x()', function() { it('returns the value of x without an argument', function() { expect(circle.x()).toBe(0) @@ -19,7 +19,7 @@ describe('Circle', function() { expect(box.x).toBeCloseTo(123) }) }) - + describe('y()', function() { it('returns the value of y without an argument', function() { expect(circle.y()).toBe(0) @@ -30,7 +30,7 @@ describe('Circle', function() { expect(box.y).toBe(345) }) }) - + describe('cx()', function() { it('returns the value of cx without an argument', function() { expect(circle.cx()).toBe(120) @@ -41,7 +41,7 @@ describe('Circle', function() { expect(box.cx).toBe(123) }) }) - + describe('cy()', function() { it('returns the value of cy without an argument', function() { expect(circle.cy()).toBe(120) @@ -81,7 +81,7 @@ describe('Circle', function() { expect(circle.node.getAttribute('r')).toBe('120') }) }) - + describe('move()', function() { it('sets the x and y position', function() { circle.move(123, 456) @@ -115,7 +115,7 @@ describe('Circle', function() { expect(circle.node.getAttribute('cy')).toBe('205') }) }) - + describe('center()', function() { it('sets the cx and cy position', function() { circle.center(321,567) @@ -144,24 +144,24 @@ describe('Circle', function() { expect((circle.height() / 2).toString()).toBe(circle.node.getAttribute('r')) }) }) - + describe('size()', function() { it('defines the r of the element', function() { circle.size(987) expect(circle.node.getAttribute('r')).toBe((987 / 2).toString()) }) }) - + describe('scale()', function() { it('should scale the element universally with one argument', function() { var box = circle.scale(2).rbox() - + expect(box.width).toBe(circle.attr('r') * 2 * 2) expect(box.height).toBe(circle.attr('r') * 2 * 2) }) it('should scale the element over individual x and y axes with two arguments', function() { var box = circle.scale(2, 3.5).rbox() - + expect(box.width).toBe(circle.attr('r') * 2 * 2) expect(box.height).toBe(circle.attr('r') * 2 * 3.5) }) @@ -169,9 +169,9 @@ describe('Circle', function() { describe('translate()', function() { it('sets the translation of an element', function() { - circle.transform({ x: 12, y: 12 }) + circle.transform({ tx: 12, ty: 12 }) expect(window.matrixStringToArray(circle.node.getAttribute('transform'))).toEqual([1,0,0,1,12,12]) }) }) - + }) diff --git a/spec/spec/doc.js b/spec/spec/doc.js index 5accd5b..f82f1cb 100644 --- a/spec/spec/doc.js +++ b/spec/spec/doc.js @@ -41,9 +41,7 @@ describe('Doc', function() { expect(SVG().addTo(document.createElement('div')).isRoot()).toBe(true) }) it('returns true when its the root element of the dom', function () { - if(parserInDoc) { - expect(draw.isRoot()).toBe(true) - } + expect(draw.isRoot()).toBe(true) }) it('returns false when parent is svg element', function () { expect(SVG().addTo(SVG()).isRoot()).toBe(false) @@ -59,7 +57,7 @@ describe('Doc', function() { }else{ expect(window.document.querySelectorAll('svg').length).toBe(cnt-1) } - + draw = SVG().addTo(drawing).size(100,100); expect(window.document.querySelectorAll('svg').length).toBe(cnt) }) diff --git a/spec/spec/element.js b/spec/spec/element.js index ca8deff..647904c 100644 --- a/spec/spec/element.js +++ b/spec/spec/element.js @@ -418,11 +418,11 @@ describe('Element', function() { it('moves the element to other parent while maintaining the same visal representation', function() { expect(rect1.toParent(nested).transform()).toEqual(jasmine.objectContaining({ - a:2, b:0, c:0, d:2, e:70, f:70 + a:2, b:0, c:0, d:2, e:120, f:120 })) expect(rect1.parent()).toEqual(nested) expect(rect2.toParent(g2).transform()).toEqual(jasmine.objectContaining({ - a:0.5, b:0, c:0, d:0.5, e:-95, f:-95 + a:0.5, b:0, c:0, d:0.5, e:-120, f:-120 })) expect(rect2.parent()).toEqual(g2) }) @@ -476,16 +476,16 @@ describe('Element', function() { expect(g2.node.parentNode).toBeFalsy() expect(rect1.transform()).toEqual(jasmine.objectContaining({ - a:2, b:0, c:0, d:2, e:70, f:70 + a:2, b:0, c:0, d:2, e:120, f:120 })) expect(rect2.transform()).toEqual(jasmine.objectContaining({ - a:0.5, b:0, c:0, d:0.5, e:45, f:45 + a:0.5, b:0, c:0, d:0.5, e:20, f:20 })) }) it('ungroups everything to the doc root when called on SVG.Doc / does not ungroup defs/parser', function() { draw.flatten() - + expect(rect1.parent()).toBe(draw) expect(rect2.parent()).toBe(draw) @@ -494,10 +494,10 @@ describe('Element', function() { expect(nested.node.parentNode).toBeFalsy() expect(rect1.transform()).toEqual(jasmine.objectContaining({ - a:2, b:0, c:0, d:2, e:70, f:70 + a:2, b:0, c:0, d:2, e:120, f:120 })) expect(rect2.transform()).toEqual(jasmine.objectContaining({ - a:0.5, b:0, c:0, d:0.5, e:45, f:45 + a:0.5, b:0, c:0, d:0.5, e:20, f:20 })) expect(draw.children().length).toBe(3+parserInDoc) // 2 * rect + defs diff --git a/spec/spec/ellipse.js b/spec/spec/ellipse.js index f6aa271..76f16e6 100644 --- a/spec/spec/ellipse.js +++ b/spec/spec/ellipse.js @@ -1,14 +1,14 @@ describe('Ellipse', function() { var ellipse - + beforeEach(function() { ellipse = draw.ellipse(240,90) }) - + afterEach(function() { draw.clear() }) - + describe('x()', function() { it('returns the value of x without an argument', function() { expect(ellipse.x()).toBe(0) @@ -19,7 +19,7 @@ describe('Ellipse', function() { expect(box.x).toBeCloseTo(123) }) }) - + describe('y()', function() { it('returns the value of y without an argument', function() { expect(ellipse.y()).toBe(0) @@ -30,7 +30,7 @@ describe('Ellipse', function() { expect(box.y).toBe(345) }) }) - + describe('cx()', function() { it('returns the value of cx without an argument', function() { expect(ellipse.cx()).toBe(120) @@ -41,7 +41,7 @@ describe('Ellipse', function() { expect(box.cx).toBe(123) }) }) - + describe('cy()', function() { it('returns the value of cy without an argument', function() { expect(ellipse.cy()).toBe(45) @@ -70,7 +70,7 @@ describe('Ellipse', function() { expect(ellipse.node.getAttribute('ry')).toBe('0') }) }) - + describe('move()', function() { it('sets the x and y position', function() { ellipse.move(123, 456) @@ -104,7 +104,7 @@ describe('Ellipse', function() { expect(ellipse.node.getAttribute('cy')).toBe('130') }) }) - + describe('center()', function() { it('sets the cx and cy position', function() { ellipse.center(321,567) @@ -133,7 +133,7 @@ describe('Ellipse', function() { expect((ellipse.height() / 2).toString()).toBe(ellipse.node.getAttribute('ry')) }) }) - + describe('size()', function() { it('defines the rx and ry of the element', function() { ellipse.size(987,654) @@ -153,17 +153,17 @@ describe('Ellipse', function() { expect(ellipse.width() / ellipse.height()).toBe(box.width / box.height) }) }) - + describe('scale()', function() { it('should scale the element universally with one argument', function() { var box = ellipse.scale(2).rbox() - + expect(box.width).toBe(ellipse.attr('rx') * 2 * 2) expect(box.height).toBe(ellipse.attr('ry') * 2 * 2) }) it('should scale the element over individual x and y axes with two arguments', function() { var box = ellipse.scale(2, 3.5).rbox() - + expect(box.width).toBe(ellipse.attr('rx') * 2 * 2) expect(box.height).toBe(ellipse.attr('ry') * 2 * 3.5) }) @@ -171,17 +171,9 @@ describe('Ellipse', function() { describe('translate()', function() { it('sets the translation of an element', function() { - ellipse.transform({ x: 12, y: 12 }) + ellipse.transform({ tx: 12, ty: 12 }) expect(ellipse.node.getAttribute('transform')).toBe('matrix(1,0,0,1,12,12)') }) }) - -}) - - - - - - - +}) diff --git a/spec/spec/matrix.js b/spec/spec/matrix.js index 08e0280..b60833c 100644 --- a/spec/spec/matrix.js +++ b/spec/spec/matrix.js @@ -18,29 +18,6 @@ describe('Matrix', function() { expect(matrix.f).toBe(0) }) - describe('decompose()', function() { - var decompose - - beforeEach(function() { - decompose = matrix.decompose() - }) - - it('parses translation values', function() { - expect(decompose.translateX).toBe(0) - expect(decompose.translateY).toBe(0) - }) - it('parses shear values', function() { - expect(decompose.shear).toBe(0) - }) - it('parses scale values', function() { - expect(decompose.scaleX).toBe(1) - expect(decompose.scaleY).toBe(1) - }) - it('parses rotatoin value', function() { - expect(decompose.rotate).toBe(0) - }) - }) - describe('toString()' , function() { it('exports correctly to a string', function() { expect(matrix.toString()).toBe('matrix(1,0,0,1,0,0)') |