mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
remove all system related data from shuttle repository
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
generateMockRoutes,
|
||||
generateMockShuttles,
|
||||
generateMockStops,
|
||||
generateMockSystems
|
||||
} from "../testHelpers/mockDataGenerators";
|
||||
|
||||
// For repositories created in the future, reuse core testing
|
||||
@@ -21,23 +20,6 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
repository = new UnoptimizedInMemoryShuttleRepository();
|
||||
});
|
||||
|
||||
describe("getSystem", () => {
|
||||
test("gets the system stored in the repository", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
await repository.updateSystem(mockSystems[0]);
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
|
||||
expect(result).toEqual(mockSystems[0]);
|
||||
});
|
||||
|
||||
test("gets null if there is no data associated with the system", async () => {
|
||||
const result = await repository.getSystemIfExists();
|
||||
|
||||
expect(result).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getStopsBySystemId", () => {
|
||||
test("gets stops by system ID", async () => {
|
||||
const mockStops = generateMockStops();
|
||||
@@ -303,18 +285,6 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateSystem", () => {
|
||||
test("adds a new system", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
const newSystem = mockSystems[0];
|
||||
|
||||
await repository.updateSystem(newSystem);
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual(newSystem);
|
||||
});
|
||||
});
|
||||
|
||||
describe("addOrUpdateRoute", () => {
|
||||
test("adds a new route if nonexistent", async () => {
|
||||
const mockRoutes = generateMockRoutes();
|
||||
@@ -440,25 +410,6 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("removeSystemIfExists", () => {
|
||||
test("removes system given ID", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
await repository.updateSystem(mockSystems[0]);
|
||||
|
||||
await repository.removeSystemIfExists();
|
||||
|
||||
const expectedSystem = await repository.getSystemIfExists();
|
||||
expect(expectedSystem).toBeNull();
|
||||
});
|
||||
|
||||
test("does nothing if system doesn't exist", async () => {
|
||||
await repository.removeSystemIfExists();
|
||||
|
||||
const expectedSystem = await repository.getSystemIfExists();
|
||||
expect(expectedSystem).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("removeRouteIfExists", () => {
|
||||
test("removes route given ID", async () => {
|
||||
const systemId = "1";
|
||||
@@ -620,19 +571,6 @@ describe("UnoptimizedInMemoryRepository", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("clearSystemData", () => {
|
||||
test("clears system data when the repository has data", async () => {
|
||||
const mockSystems = generateMockSystems();
|
||||
const system = mockSystems[0];
|
||||
await repository.updateSystem(system);
|
||||
|
||||
await repository.clearSystemData();
|
||||
|
||||
const result = await repository.getSystemIfExists();
|
||||
expect(result).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("clearShuttleData", () => {
|
||||
test("clears all shuttles from the repository", async () => {
|
||||
const mockShuttles = generateMockShuttles();
|
||||
|
||||
Reference in New Issue
Block a user