File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -360,14 +360,14 @@ class BuildingPart {
360360 // remove final character.
361361 return parseFloat ( length . substring ( 0 , length . length - 2 ) ) * 1000 ;
362362 }
363- if ( length . includes ( 'mi' ) ) {
364- // remove final character.
365- return parseFloat ( length . substring ( 0 , length . length - 2 ) ) * 5280 * 12 * 2.54 / 100 ;
366- }
367363 if ( length . includes ( 'nmi' ) ) {
368364 // remove final character.
369365 return parseFloat ( length . substring ( 0 , length . length - 3 ) ) * 1852 ;
370366 }
367+ if ( length . includes ( 'mi' ) ) {
368+ // remove final character.
369+ return parseFloat ( length . substring ( 0 , length . length - 2 ) ) * 5280 * 12 * 2.54 / 100 ;
370+ }
371371 if ( length . includes ( 'm' ) ) {
372372 // remove final character.
373373 return parseFloat ( length . substring ( 0 , length . length - 1 ) ) ;
Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ test('Constructor', () => {
6767 expect ( errors . length ) . toBe ( 0 ) ;
6868} ) ;
6969
70+ test ( 'Normalize Length' , ( ) => {
71+ expect ( BuildingPart . normalizeLength ( '5km' ) ) . toBe ( 5000 ) ;
72+ expect ( BuildingPart . normalizeLength ( '1mi' ) ) . toBe ( 1609.344 ) ;
73+ expect ( BuildingPart . normalizeLength ( '1nmi' ) ) . toBe ( 1852 ) ;
74+ } ) ;
75+
7076window . printError = printError ;
7177
7278var errors = [ ] ;
You can’t perform that action at this time.
0 commit comments