From 900f86cb1f7b17a2a3b6c8f7d749a0319e34a917 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 3 Apr 2014 19:44:18 +0200 Subject: [PATCH] added a Test to check Element.children() as title says --- svgjs/svgjs-tests.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index 60d07cab5..0a0a2357c 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -86,3 +86,27 @@ function elementTransformShouldReturnTransformObject() { if (trans.skewX != 10) { throw "skewX value is not correct" } if (trans.skewY != 25) { throw "skewY value is not correct" } } + +//Test if svgjs.Element.children() correctly return an svgjs.Element[] +function elementTransformShouldReturnTransformObject() { + /* create an svg drawing */ + var div = document.createElement('div') + var draw = SVG(div) + + /* draw a rectangle scale, rotate and skew it */ + var group = draw.group() + group.rect(10,10) + group.rect(20,20) + group.rect(30,30) + group.rect(40,40) + group.rect(50,50) + + /* first try to cast it */ + var result:svgjs.Element[] = group.children() + /* then check values if they are correct */ + if (!(result[0] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[1] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[2] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[3] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[4] instanceof svgjs.Element)) { throw "Element.children() is not working" } +}