@@ -82,23 +82,24 @@ test('Test combining 3 ways 1->2->3', () => {
8282 expect ( result [ 0 ] . getElementsByTagName ( 'nd' ) . length ) . toBe ( 4 ) ;
8383} ) ;
8484
85- tests = [
86- [ [
87- '<way id="1"><nd ref="1"/><nd ref="2"/></way>' ,
88- '<way id="2"><nd ref="3"/><nd ref="4"/></way>' ,
89- '<way id="3"><nd ref="4"/><nd ref="1"/></way>' ,
90- '<way id="4"><nd ref="2"/><nd ref="3"/></way>' ,
91- ] , 1 , 4 ] ,
92- ] ;
93- test . each ( ) ( 'Test combining 4 ways' , ( ways , length , nodes ) => {
94- let parser = new window . DOMParser ( ) ;
95- xml = [ ] ;
96- for ( const way of ways ) {
97- xml . push ( parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ) ;
98- }
99- let result = BuildingShapeUtils . combineWays ( xml ) ;
100- expect ( result . length ) . toBe ( length ) ;
101- expect ( BuildingShapeUtils . isClosed ( result [ 0 ] ) ) ;
102- expect ( BuildingShapeUtils . isSelfIntersecting ( result [ 0 ] ) ) . toBe ( false ) ;
103- expect ( result [ 0 ] . getElementsByTagName ( 'nd' ) . length ) . toBe ( nodes ) ;
85+ describe ( 'Combine Ways' , ( ) => {
86+ test . each ( [
87+ [ [
88+ '<way id="1"><nd ref="1"/><nd ref="2"/></way>' ,
89+ '<way id="2"><nd ref="3"/><nd ref="4"/></way>' ,
90+ '<way id="3"><nd ref="4"/><nd ref="1"/></way>' ,
91+ '<way id="4"><nd ref="2"/><nd ref="3"/></way>' ,
92+ ] , 1 , 4 , 'Test combining 4 ways' ,
93+ ] ) ( '${description}' , ( ways , length , nodes , description ) => {
94+ let parser = new window . DOMParser ( ) ;
95+ xml = [ ] ;
96+ for ( const way of ways ) {
97+ xml . push ( parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ) ;
98+ }
99+ let result = BuildingShapeUtils . combineWays ( xml ) ;
100+ expect ( result . length ) . toBe ( length ) ;
101+ expect ( BuildingShapeUtils . isClosed ( result [ 0 ] ) ) ;
102+ expect ( BuildingShapeUtils . isSelfIntersecting ( result [ 0 ] ) ) . toBe ( false ) ;
103+ expect ( result [ 0 ] . getElementsByTagName ( 'nd' ) . length ) . toBe ( nodes ) ;
104+ } ) ;
104105} ) ;
0 commit comments