mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Make the ETA assertion check for multiple ETA insertions
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user