77describe ( 'Pathformer' , function ( ) {
88
99 var svgTag ,
10- svgTagId = 'my-svg' ;
10+ svgTagId = 'my-svg' ,
11+ svgGroupTag ,
12+ svgGroupTagId = 'my-svg-group' ;
1113
1214 beforeEach ( function ( ) {
1315 // Remove tag if existing
@@ -18,13 +20,17 @@ describe('Pathformer', function () {
1820
1921 // Create the SVG
2022 svgTag = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'svg' ) ;
21- svgTag . id = 'my-svg' ;
23+ svgTag . id = svgTagId ;
2224 svgTag . innerHTML = '<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="72.947"/>' +
2325 '<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="39.74"/>' +
26+ '<g id="' + svgGroupTagId + '">' +
2427 '<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="34.042" y1="131.189" x2="67.047" y2="77.781"/>' +
2528 '<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="165.957" y1="68.809" x2="132.953" y2="122.219"/>' +
2629 '<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="131.19" y1="165.957" x2="77.781" y2="132.953"/>' +
27- '<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="68.81" y1="34.042" x2="122.219" y2="67.046"/>' ;
30+ '<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="68.81" y1="34.042" x2="122.219" y2="67.046"/>' +
31+ '</g>' ;
32+
33+ svgGroupTag = svgTag . querySelector ( '#' + svgGroupTagId ) ;
2834
2935 // Insert it to the body
3036 document . body . appendChild ( svgTag ) ;
@@ -51,6 +57,12 @@ describe('Pathformer', function () {
5157 } ) . not . toThrow ( ) ;
5258 } ) ;
5359
60+ it ( 'should work with only the SVG group object' , function ( ) {
61+ expect ( function ( ) {
62+ new Pathformer ( svgGroupTag ) ;
63+ } ) . not . toThrow ( ) ;
64+ } ) ;
65+
5466 it ( 'should throw an error if the SVG ID given is invalid' , function ( ) {
5567 expect ( function ( ) {
5668 new Pathformer ( 'my-unexisting-svg' ) ;
0 commit comments