@@ -43,7 +43,7 @@ it('calculates a total pit time if both pit-in and pit-out have been seen', () =
4343 const generator = new MessageGenerator ( ) ;
4444
4545 generator . generate ( { colSpec } , { cars : oldCars , lastUpdated : 0 } , { cars : pitInCars , lastUpdated : 0 } ) ;
46- const outMsgs = generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitOutCars , lastUpdated : 123 } ) ;
46+ const outMsgs = generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitOutCars , lastUpdated : 123000 } ) ;
4747
4848 expect ( outMsgs . length ) . toEqual ( 1 ) ;
4949 expect ( outMsgs [ 0 ] [ 2 ] ) . toEqual ( '#1 (John Hindhaugh) has left the pits (pit time: 2:03)' ) ;
@@ -58,11 +58,11 @@ it('calculates a total pit time if both pit-in and pit-out have been seen and ca
5858 const generator = new MessageGenerator ( ) ;
5959
6060 generator . generate ( { colSpec } , { cars : oldCars , lastUpdated : 0 } , { cars : pitInCars , lastUpdated : 0 } ) ;
61- generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitFuelCars , lastUpdated : 62 } ) ;
62- const outMsgs = generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitOutCars , lastUpdated : 123 } ) ;
61+ generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitFuelCars , lastUpdated : 62000 } ) ;
62+ const outMsgs = generator . generate ( { colSpec } , { cars : pitFuelCars , lastUpdated : 62000 } , { cars : pitOutCars , lastUpdated : 123000 } ) ;
6363
6464 expect ( outMsgs . length ) . toEqual ( 1 ) ;
65- expect ( outMsgs [ 0 ] [ 2 ] ) . toEqual ( '#1 (John Hindhaugh) has left the pits (pit time: 2:03)' ) ;
65+ expect ( outMsgs [ 0 ] [ 2 ] ) . toEqual ( '#1 (John Hindhaugh) has left the pits (total pit time: 2:03, 1:01 fuel )' ) ;
6666} ) ;
6767
6868it ( 'calculates total pit time and fuel time if both pit-in and pit-out have been seen and car comes in via fuelling area' , ( ) => {
@@ -74,9 +74,10 @@ it('calculates total pit time and fuel time if both pit-in and pit-out have been
7474 const generator = new MessageGenerator ( ) ;
7575
7676 generator . generate ( { colSpec } , { cars : oldCars , lastUpdated : 0 } , { cars : pitFuelCars , lastUpdated : 0 } ) ;
77- generator . generate ( { colSpec } , { cars : pitFuelCars , lastUpdated : 0 } , { cars : pitInCars , lastUpdated : 62 } ) ;
78- const outMsgs = generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 0 } , { cars : pitOutCars , lastUpdated : 123 } ) ;
77+ generator . generate ( { colSpec } , { cars : pitFuelCars , lastUpdated : 0 } , { cars : pitInCars , lastUpdated : 52499 } ) ;
78+ // Also demonstrating rounding to the nearest second
79+ const outMsgs = generator . generate ( { colSpec } , { cars : pitInCars , lastUpdated : 52499 } , { cars : pitOutCars , lastUpdated : 123499 } ) ;
7980
8081 expect ( outMsgs . length ) . toEqual ( 1 ) ;
81- expect ( outMsgs [ 0 ] [ 2 ] ) . toEqual ( '#1 (John Hindhaugh) has left the pits (total pit time: 2:03, 1:02 fuel)' ) ;
82+ expect ( outMsgs [ 0 ] [ 2 ] ) . toEqual ( '#1 (John Hindhaugh) has left the pits (total pit time: 2:03, 0:52 fuel)' ) ;
8283} ) ;
0 commit comments