mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Test that clearShuttleData also clears last stop data
This commit is contained in:
@@ -18,7 +18,7 @@ class UnoptimizedInMemoryShuttleRepositoryHolder implements RepositoryHolder<Shu
|
||||
factory = async () => {
|
||||
return new UnoptimizedInMemoryShuttleRepository();
|
||||
};
|
||||
teardown = async () => {};
|
||||
teardown = async () => { };
|
||||
}
|
||||
|
||||
class RedisShuttleRepositoryHolder implements RepositoryHolder<ShuttleGetterSetterRepository> {
|
||||
@@ -477,6 +477,28 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
const result = await repository.getShuttles();
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
test("also clears last stop data", async () => {
|
||||
const { route, stop1, stop2, systemId } = await setupRouteAndOrderedStops();
|
||||
|
||||
const mockShuttles = generateMockShuttles();
|
||||
mockShuttles[0].coordinates = stop1.coordinates;
|
||||
mockShuttles[1].coordinates = stop2.coordinates;
|
||||
|
||||
for (const shuttle of mockShuttles) {
|
||||
shuttle.routeId = route.id;
|
||||
shuttle.systemId = systemId;
|
||||
|
||||
await repository.addOrUpdateShuttle(shuttle);
|
||||
}
|
||||
|
||||
await repository.clearShuttleData();
|
||||
|
||||
for (const shuttle of mockShuttles) {
|
||||
const result = await repository.getShuttleLastStopArrival(shuttle.id);
|
||||
expect(result).toBeUndefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user