mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add tests for shuttles and stops
This commit is contained in:
@@ -429,7 +429,7 @@ describe("UnoptimizedInMemoryRepository", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeSystem", () => {
|
describe("removeSystemIfExists", () => {
|
||||||
test("removes system given ID", async () => {
|
test("removes system given ID", async () => {
|
||||||
const mockSystems = generateMockSystems();
|
const mockSystems = generateMockSystems();
|
||||||
await Promise.all(mockSystems.map(async (system) => {
|
await Promise.all(mockSystems.map(async (system) => {
|
||||||
@@ -456,7 +456,7 @@ describe("UnoptimizedInMemoryRepository", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeRoute", () => {
|
describe("removeRouteIfExists", () => {
|
||||||
test("removes route given ID", async () => {
|
test("removes route given ID", async () => {
|
||||||
const systemId = "1";
|
const systemId = "1";
|
||||||
const mockRoutes = generateMockRoutes();
|
const mockRoutes = generateMockRoutes();
|
||||||
@@ -487,27 +487,69 @@ describe("UnoptimizedInMemoryRepository", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeShuttle", () => {
|
describe("removeShuttleIfExists", () => {
|
||||||
test("removes shuttle given ID", async () => {
|
test("removes shuttle given ID", async () => {
|
||||||
|
const systemId = "1";
|
||||||
|
const mockShuttles = generateMockShuttles();
|
||||||
|
await Promise.all(mockShuttles.map(async (shuttle) => {
|
||||||
|
shuttle.systemId = systemId;
|
||||||
|
await repository.addOrUpdateShuttle(shuttle);
|
||||||
|
}));
|
||||||
|
|
||||||
|
const shuttleToRemove = mockShuttles[0];
|
||||||
|
await repository.removeShuttleIfExists(shuttleToRemove.id);
|
||||||
|
|
||||||
|
const remainingShuttles = await repository.getShuttlesBySystemId(systemId);
|
||||||
|
expect(remainingShuttles).toHaveLength(mockShuttles.length - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does nothing if shuttle doesn't exist", async () => {
|
test("does nothing if shuttle doesn't exist", async () => {
|
||||||
|
const systemId = "1";
|
||||||
|
const mockShuttles = generateMockShuttles();
|
||||||
|
await Promise.all(mockShuttles.map(async (shuttle) => {
|
||||||
|
shuttle.systemId = systemId;
|
||||||
|
await repository.addOrUpdateShuttle(shuttle);
|
||||||
|
}));
|
||||||
|
|
||||||
|
await repository.removeShuttleIfExists("nonexistent-id");
|
||||||
|
|
||||||
|
const remainingShuttles = await repository.getShuttlesBySystemId(systemId);
|
||||||
|
expect(remainingShuttles).toHaveLength(mockShuttles.length);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeStop", () => {
|
describe("removeStopIfExists", () => {
|
||||||
test("removes stop given ID", async () => {
|
test("removes stop given ID", async () => {
|
||||||
|
const systemId = "1";
|
||||||
|
const mockStops = generateMockStops();
|
||||||
|
await Promise.all(mockStops.map(async (stop) => {
|
||||||
|
stop.systemId = systemId;
|
||||||
|
await repository.addOrUpdateStop(stop);
|
||||||
|
}));
|
||||||
|
|
||||||
|
const stopToRemove = mockStops[0];
|
||||||
|
await repository.removeStopIfExists(stopToRemove.id);
|
||||||
|
|
||||||
|
const remainingStops = await repository.getStopsBySystemId(systemId);
|
||||||
|
expect(remainingStops).toHaveLength(mockStops.length - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does nothing if stop doesn't exist", async () => {
|
test("does nothing if stop doesn't exist", async () => {
|
||||||
|
const systemId = "1";
|
||||||
|
const mockStops = generateMockStops();
|
||||||
|
await Promise.all(mockStops.map(async (stop) => {
|
||||||
|
stop.systemId = systemId;
|
||||||
|
await repository.addOrUpdateStop(stop);
|
||||||
|
}));
|
||||||
|
|
||||||
|
await repository.removeStopIfExists("nonexistent-id");
|
||||||
|
|
||||||
|
const remainingStops = await repository.getStopsBySystemId(systemId);
|
||||||
|
expect(remainingStops).toHaveLength(mockStops.length);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeOrderedStop", () => {
|
describe("removeOrderedStopIfExists", () => {
|
||||||
test("removes ordered stop given stop ID and route ID", async () => {
|
test("removes ordered stop given stop ID and route ID", async () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -517,7 +559,7 @@ describe("UnoptimizedInMemoryRepository", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("removeEta", () => {
|
describe("removeEtaIfExists", () => {
|
||||||
test("removes eta given shuttle ID and stop ID", async () => {
|
test("removes eta given shuttle ID and stop ID", async () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user