From 42c71815e66cc530d1d396b5961a1b65b3a61702 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 13 Nov 2025 17:13:43 -0800 Subject: [PATCH] Make the ETA assertion check for multiple ETA insertions --- ...lfUpdatingETARepositorySharedTests.test.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts b/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts index 40ac15c..f490b0f 100644 --- a/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts +++ b/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts @@ -118,10 +118,12 @@ describe.each(repositoryImplementations)('$name', (holder) => { currentTime: Date, shuttleSecondArrivalTimeAtFirstStop: Date ) { - const { route, systemId, stop1, stop2 } = await setupRouteAndOrderedStops(); + const { route, systemId, stop1, stop2, stop3 } = await setupRouteAndOrderedStops(); - const firstStopLastWeekArrivalTime = new Date(2025, 0, 1, 12, 0, 0); - const secondStopLastWeekArrivalTime = new Date(2025, 0, 1, 12, 15, 0); + // Populating travel time data + const firstStopArrivalTime = new Date(2025, 0, 1, 12, 0, 0); + const secondStopArrivalTime = new Date(2025, 0, 1, 12, 15, 0); + const thirdStopArrivalTime = new Date(2025, 0, 1, 12, 20, 0); repository.setReferenceTime(currentTime); repository.startListeningForUpdates(); @@ -136,11 +138,15 @@ describe.each(repositoryImplementations)('$name', (holder) => { updatedTime: new Date(), }; - await shuttleRepository.addOrUpdateShuttle(shuttle, firstStopLastWeekArrivalTime.getTime()); + await shuttleRepository.addOrUpdateShuttle(shuttle, firstStopArrivalTime.getTime()); shuttle.coordinates = stop2.coordinates; - await shuttleRepository.addOrUpdateShuttle(shuttle, secondStopLastWeekArrivalTime.getTime()); + await shuttleRepository.addOrUpdateShuttle(shuttle, secondStopArrivalTime.getTime()); + shuttle.coordinates = stop3.coordinates; + await shuttleRepository.addOrUpdateShuttle(shuttle, thirdStopArrivalTime.getTime()); + + // Populating ETA data shuttle.coordinates = stop1.coordinates; await shuttleRepository.addOrUpdateShuttle( shuttle, @@ -155,11 +161,14 @@ describe.each(repositoryImplementations)('$name', (holder) => { await new Promise((resolve) => setTimeout(resolve, 1000)); - const eta = await repository.getEtaForShuttleAndStopId(shuttle.id, stop2.id); - expect(eta?.secondsRemaining).toEqual(8 * 60); + const secondStopEta = await repository.getEtaForShuttleAndStopId(shuttle.id, stop2.id); + expect(secondStopEta?.secondsRemaining).toEqual(8 * 60); + + const thirdStopEta = await repository.getEtaForShuttleAndStopId(shuttle.id, stop3.id); + expect(thirdStopEta?.secondsRemaining).toEqual(13 * 60); } - test("adds an ETA entry based on historical data", async () => { + test("adds ETA entries for stops based on historical data", async () => { const shuttleSecondArrivalTimeAtFirstStop = new Date(2025, 0, 8, 12, 0, 0); const currentTime = new Date(shuttleSecondArrivalTimeAtFirstStop.getTime() + 7 * 60 * 1000);