diff --git a/test/repositories/UnoptimizedInMemoryRepositoryTests.test.ts b/test/repositories/UnoptimizedInMemoryRepositoryTests.test.ts index 8d5dcb7..531cd00 100644 --- a/test/repositories/UnoptimizedInMemoryRepositoryTests.test.ts +++ b/test/repositories/UnoptimizedInMemoryRepositoryTests.test.ts @@ -431,21 +431,59 @@ describe("UnoptimizedInMemoryRepository", () => { describe("removeSystem", () => { test("removes system given ID", async () => { + const mockSystems = generateMockSystems(); + await Promise.all(mockSystems.map(async (system) => { + await repository.addOrUpdateSystem(system); + })); + const systemToRemove = mockSystems[0]; + await repository.removeSystemIfExists(systemToRemove.id); + + const remainingSystems = await repository.getSystems(); + expect(remainingSystems).toHaveLength(mockSystems.length - 1); }); test("does nothing if system doesn't exist", async () => { + const mockSystems = generateMockSystems(); + await Promise.all(mockSystems.map(async (system) => { + await repository.addOrUpdateSystem(system); + })); + await repository.removeSystemIfExists("nonexistent-id"); + + const remainingSystems = await repository.getSystems(); + expect(remainingSystems).toHaveLength(mockSystems.length); }); }); describe("removeRoute", () => { test("removes route given ID", async () => { + const systemId = "1"; + const mockRoutes = generateMockRoutes(); + await Promise.all(mockRoutes.map(async (route) => { + route.systemId = systemId; + await repository.addOrUpdateRoute(route); + })); + const routeToRemove = mockRoutes[0]; + await repository.removeRouteIfExists(routeToRemove.id); + + const remainingRoutes = await repository.getRoutesBySystemId(systemId); + expect(remainingRoutes).toHaveLength(mockRoutes.length - 1); }); test("does nothing if route doesn't exist", async () => { + const systemId = "1"; + const mockRoutes = generateMockRoutes(); + await Promise.all(mockRoutes.map(async (route) => { + route.systemId = systemId; + await repository.addOrUpdateRoute(route); + })); + await repository.removeRouteIfExists("nonexistent-id"); + + const remainingRoutes = await repository.getRoutesBySystemId(systemId); + expect(remainingRoutes).toHaveLength(mockRoutes.length); }); });