diff --git a/test/path.js b/test/path.js index f400240..e5d6b8c 100644 --- a/test/path.js +++ b/test/path.js @@ -53,7 +53,7 @@ describe("Path methods", function () { alpha: 180 }); }); - it("Savage.path.bezierBBox", function () { + it("Savage.path.bezierBBox - params", function () { var bbox = Savage.path.bezierBBox(10, 10, 10, 20, 110, 0, 110, 10); expect(bbox.cx).to.be(60); expect(bbox.cy).to.be(10); @@ -62,6 +62,25 @@ describe("Path methods", function () { expect(bbox.width).to.be(100); expect(bbox.x2).to.be(110); }); + it("Savage.path.bezierBBox - array", function () { + var bbox = Savage.path.bezierBBox([10, 10, 10, 20, 110, 0, 110, 10]); + expect(bbox.cx).to.be(60); + expect(bbox.cy).to.be(10); + expect(bbox.x).to.be(10); + expect(bbox.w).to.be(100); + expect(bbox.width).to.be(100); + expect(bbox.x2).to.be(110); + }); + it("Savage.path.getBBox", function() { + // same as 10,20,30,40 rect + var bbox = Savage.path.getBBox("M10,20h30v40h-30z"); + expect(bbox.x).to.eql(10); + expect(bbox.y).to.eql(20); + expect(bbox.width).to.eql(30); + expect(bbox.height).to.eql(40); + expect(bbox.x2).to.eql(10 + 30); + expect(bbox.y2).to.eql(20 + 40); + }); it("Savage.path.isPointInsideBBox", function () { expect(Savage.path.isPointInsideBBox({x: 0, y: 0, width: 10, height: 10}, 5, 5)).to.be(true); expect(Savage.path.isPointInsideBBox({x: 0, y: 0, width: 10, height: 10}, 10, 5)).to.be(true); diff --git a/test/primitives.js b/test/primitives.js index 4eb2b8b..56303c6 100644 --- a/test/primitives.js +++ b/test/primitives.js @@ -94,6 +94,14 @@ describe("Primitives creation", function () { expect(C).to.not.be(null); expect(C.childNodes.length).to.be(2); }); + it("creates and fills a group on creation", function () { + var circle1 = s.circle(10, 10, 10); + var circle2 = s.circle(20, 10, 10); + var group = s.g(circle1, circle2); + var groupEl = document.querySelector("g"); + expect(groupEl).to.not.be(null); + expect(groupEl.childNodes.length).to.be(2); + }); it("creates a text", function () { var c = s.text(10, 10, "test"); var C = document.querySelector("text"); diff --git a/test/savage-tests.js b/test/savage-tests.js index 432c60b..4e597b9 100644 --- a/test/savage-tests.js +++ b/test/savage-tests.js @@ -396,4 +396,18 @@ describe("Savage methods", function () { expect(bbox.x2).to.eql(10 + 30); expect(bbox.y2).to.eql(20 + 40); }); + it("Savage.angle - 2 points", function() { + var angle = Savage.angle(0, 0, 10, 10); + expect(angle).to.not.be(0); + expect(angle % 45).to.be(0); + angle = Savage.angle(0, 0, 10, 0); + expect(angle % 90).to.be(0); + }); + it("Savage.angle - 3 points", function() { + var angle = Savage.angle(10, 0, 0, 10, 0, 0); + expect(angle).to.not.be(0); + expect(angle % 45).to.be(0); + angle = Savage.angle(10, 0, 0, 10, 0, 0); + expect(Math.abs(angle)).to.be(90); + }); }); \ No newline at end of file