@@ -76,31 +76,15 @@ test('Longest side angle', () => {
7676 expect ( BuildingShapeUtils . longestSideAngle ( rightTriangle ) ) . toBe ( - Math . PI / 4 ) ;
7777} ) ;
7878
79- // Combine these next 4 into a test runner.
80- test ( 'non-intersecting open way' , ( ) => {
81- const way = '<way id="1"><nd ref="1"/><nd ref="2"/></way>' ;
82- let parser = new window . DOMParser ( ) ;
83- let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
84- expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( false ) ;
85- } ) ;
86-
87- test ( 'non-intersecting closed way' , ( ) => {
88- const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1"/></way>' ;
89- let parser = new window . DOMParser ( ) ;
90- let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
91- expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( false ) ;
92- } ) ;
93-
94- test ( 'intersecting open way' , ( ) => {
95- const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2"/></way>' ;
96- let parser = new window . DOMParser ( ) ;
97- let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
98- expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( true ) ;
99- } ) ;
100-
101- test ( 'intersecting closed way' , ( ) => {
102- const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="3"/><nd ref="1"/></way>' ;
103- let parser = new window . DOMParser ( ) ;
104- let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
105- expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( true ) ;
79+ describe ( 'isSelfIntersecting' , ( ) => {
80+ test . each ( [
81+ [ '<way id="1"><nd ref="1"/><nd ref="2"/></way>' , false , 'open non-intersecting' ] ,
82+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1"/></way>' , false , 'closed non-intersecting' ] ,
83+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2"/></way>' , true ', 'open intersecting' ] ,
84+ [ '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="3"/><nd ref="1"/></way>' , true , 'closed intersecting' ]
85+ ] ) ( $ { description} , ( way , expected , description ) => {
86+ let parser = new window . DOMParser ( ) ;
87+ let xml = parser . parseFromString ( way , 'text/xml' ) . getElementsByTagName ( 'way' ) [ 0 ] ;
88+ expect ( BuildingShapeUtils . isSelfIntersecting ( xml ) ) . toBe ( expected ) ;
89+ } ) ;
10690} ) ;
0 commit comments