From 88a393c1adc86b744c0352d982a3a28e719522f3 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 11 Nov 2025 19:41:42 -0800 Subject: [PATCH] Update ETA add test to use setReferenceTime --- .../SelfUpdatingETARepositorySharedTests.test.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts b/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts index a3a0eb2..8003c41 100644 --- a/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts +++ b/src/repositories/shuttle/eta/__tests__/SelfUpdatingETARepositorySharedTests.test.ts @@ -91,6 +91,9 @@ describe.each(repositoryImplementations)('$name', (holder) => { test("adds an ETA entry based on historical data", async () => { const { route, systemId, stop1, stop2 } = await setupRouteAndOrderedStops(); + const shuttleSecondArrivalTimeAtFirstStop = new Date(2025, 0, 8, 12, 0, 0); + // "current time" is 7 minutes past arrival, expected eta = 8 minutes + repository.setReferenceTime(new Date(shuttleSecondArrivalTimeAtFirstStop.getTime() + 7 * 60 * 1000)); repository.startListeningForUpdates(); const shuttle = { @@ -103,21 +106,21 @@ describe.each(repositoryImplementations)('$name', (holder) => { updatedTime: new Date(), }; - const firstStopArrivalTime = new Date(2025, 0, 1, 12, 0, 0); - await shuttleRepository.addOrUpdateShuttle(shuttle, firstStopArrivalTime.getTime()); + const firstStopLastWeekArrivalTime = new Date(2025, 0, 1, 12, 0, 0); + await shuttleRepository.addOrUpdateShuttle(shuttle, firstStopLastWeekArrivalTime.getTime()); shuttle.coordinates = stop2.coordinates; - const secondStopArrivalTime = new Date(2025, 0, 1, 12, 15, 0); - await shuttleRepository.addOrUpdateShuttle(shuttle, secondStopArrivalTime.getTime()); + const secondStopLastWeekArrivalTime = new Date(2025, 0, 1, 12, 15, 0); + await shuttleRepository.addOrUpdateShuttle(shuttle, secondStopLastWeekArrivalTime.getTime()); shuttle.coordinates = stop1.coordinates; await shuttleRepository.addOrUpdateShuttle( shuttle, - new Date(2025, 0, 8, 12, 0, 0).getTime(), + shuttleSecondArrivalTimeAtFirstStop.getTime(), ); const eta = await repository.getEtaForShuttleAndStopId(shuttle.id, stop2.id); - expect(eta?.secondsRemaining).toEqual(7 * 60 + 30); + expect(eta?.secondsRemaining).toEqual(8 * 60); }); });