add remaining tests for 100% test coverage

This commit is contained in:
2025-01-21 15:01:21 -08:00
parent 736d348133
commit bfd4c40a10

View File

@@ -444,26 +444,101 @@ describe("UnoptimizedInMemoryRepository", () => {
}); });
describe("clearSystemData", () => { describe("clearSystemData", () => {
test("clears all systems from the repository", async () => {
const system1 = { id: "sys1", name: "System A" };
const system2 = { id: "sys2", name: "System B" };
await repository.addOrUpdateSystem(system1);
await repository.addOrUpdateSystem(system2);
await repository.clearSystemData();
const result = await repository.getSystems();
expect(result).toEqual([]);
});
test("clears system data when the repository has data", async () => {
const system = { id: "sys1", name: "System A" };
await repository.addOrUpdateSystem(system);
await repository.clearSystemData();
const result = await repository.getSystems();
expect(result).toEqual([]);
});
}); });
describe("clearShuttleData", () => { describe("clearShuttleData", () => {
test("clears all shuttles from the repository", async () => {
const shuttle1 = { id: "shuttle1", name: "Shuttle A", systemId: "sys1", routeId: "route1", coordinates: { latitude: 10, longitude: 20 } };
const shuttle2 = { id: "shuttle2", name: "Shuttle B", systemId: "sys2", routeId: "route2", coordinates: { latitude: 15, longitude: 25 } };
await repository.addOrUpdateShuttle(shuttle1);
await repository.addOrUpdateShuttle(shuttle2);
await repository.clearShuttleData();
const result = await repository.getShuttlesBySystemId("sys1");
expect(result).toEqual([]);
});
}); });
describe("clearEtaData", () => { describe("clearEtaData", () => {
test("clears all ETAs from the repository", async () => {
const eta1 = { shuttleId: "shuttle1", stopId: "stop1", secondsRemaining: 120 };
const eta2 = { shuttleId: "shuttle2", stopId: "stop2", secondsRemaining: 150 };
await repository.addOrUpdateEta(eta1);
await repository.addOrUpdateEta(eta2);
await repository.clearEtaData();
const result = await repository.getEtasForShuttleId("shuttle1");
expect(result).toEqual([]);
});
}); });
describe("clearOrderedStopData", () => { describe("clearOrderedStopData", () => {
test("clears all ordered stops from the repository", async () => {
const orderedStop1 = { routeId: "route1", stopId: "stop1", position: 1 };
const orderedStop2 = { routeId: "route2", stopId: "stop2", position: 2 };
await repository.addOrUpdateOrderedStop(orderedStop1);
await repository.addOrUpdateOrderedStop(orderedStop2);
await repository.clearOrderedStopData();
const result = await repository.getOrderedStopsByRouteId("route1");
expect(result).toEqual([]);
});
}); });
describe("clearRouteData", () => { describe("clearRouteData", () => {
test("clears all routes from the repository", async () => {
const route1 = { id: "route1", name: "Route 1", systemId: "sys1", color: "#ffffff", polylineCoordinates: [] };
const route2 = { id: "route2", name: "Route 2", systemId: "sys2", color: "#ffffff", polylineCoordinates: [] };
await repository.addOrUpdateRoute(route1);
await repository.addOrUpdateRoute(route2);
await repository.clearRouteData();
const result = await repository.getRoutesBySystemId("sys1");
expect(result).toEqual([]);
});
}); });
describe("clearStopData", () => { describe("clearStopData", () => {
test("clears all stops from the repository", async () => {
const stop1 = { id: "stop1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 } };
const stop2 = { id: "stop2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 10, longitude: 20 } };
await repository.addOrUpdateStop(stop1);
await repository.addOrUpdateStop(stop2);
await repository.clearStopData();
const result = await repository.getStopsBySystemId("sys1");
expect(result).toEqual([]);
});
}); });
}); });