From 4fbbc8c6e3694630317d1fdd66e4917db889cf88 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 27 Mar 2014 21:36:45 +0100 Subject: [PATCH] added a test for Element.transform() Test if svgjs.Element.transform() correctly return an svgjs.Element.Transform --- svgjs/svgjs-tests.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index fce9c3a74..60d07cab5 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -66,4 +66,23 @@ function renderSVG(data:string) { var uniqueId = "path"+index++ path.attr({"path-id": uniqueId}) }) -} \ No newline at end of file +} + +//Test if svgjs.Element.transform() correctly return an svgjs.Element.Transform +function elementTransformShouldReturnTransformObject() { + /* create an svg drawing */ + var div = document.createElement('div') + var draw = SVG(div) + + /* draw a rectangle scale, rotate and skew it */ + var rect = draw.rect(50,50).move(100,100).scale(0.5, 0.3).rotate(35).skew(10,25) + + /* first try to cast it */ + var trans:svgjs.Transform = rect.transform() + /* then check values if they are correct */ + if (trans.scaleX != 0.5) { throw "scaleX value is not correct" } + if (trans.scaleY != 0.3) { throw "scaleY value is not correct" } + if (trans.rotation != 35) { throw "rotation value is not correct" } + if (trans.skewX != 10) { throw "skewX value is not correct" } + if (trans.skewY != 25) { throw "skewY value is not correct" } +}