mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +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 () => {
|
factory = async () => {
|
||||||
return new UnoptimizedInMemoryShuttleRepository();
|
return new UnoptimizedInMemoryShuttleRepository();
|
||||||
};
|
};
|
||||||
teardown = async () => {};
|
teardown = async () => { };
|
||||||
}
|
}
|
||||||
|
|
||||||
class RedisShuttleRepositoryHolder implements RepositoryHolder<ShuttleGetterSetterRepository> {
|
class RedisShuttleRepositoryHolder implements RepositoryHolder<ShuttleGetterSetterRepository> {
|
||||||
@@ -477,6 +477,28 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
|||||||
const result = await repository.getShuttles();
|
const result = await repository.getShuttles();
|
||||||
expect(result).toEqual([]);
|
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