rename update method and update return types

This commit is contained in:
2025-04-06 09:51:13 -07:00
parent 7e0c1f3539
commit 695fec1fce
10 changed files with 26 additions and 28 deletions

View File

@@ -35,7 +35,7 @@ describe("ApiBasedRepositoryLoader", () => {
// Arrange
const systemsToPrune = generateMockSystems();
await Promise.all(systemsToPrune.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
await loader.repository.updateSystem(system);
}));
const numberOfSystemsInResponse = fetchSystemDataSuccessfulResponse.all.length;
@@ -78,7 +78,7 @@ describe("ApiBasedRepositoryLoader", () => {
const systems = generateMockSystems();
await Promise.all(systems.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
await loader.repository.updateSystem(system);
}));
await loader.fetchAndUpdateRouteDataForExistingSystemsInRepository();
@@ -128,7 +128,7 @@ describe("ApiBasedRepositoryLoader", () => {
const systems = generateMockSystems();
await Promise.all(systems.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
await loader.repository.updateSystem(system);
}));
await loader.fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystemsInRepository();
@@ -183,7 +183,7 @@ describe("ApiBasedRepositoryLoader", () => {
const systems = generateMockSystems();
await Promise.all(systems.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
await loader.repository.updateSystem(system);
}))
await loader.fetchAndUpdateShuttleDataForExistingSystemsInRepository();
@@ -226,7 +226,7 @@ describe("ApiBasedRepositoryLoader", () => {
const systems = generateMockSystems();
await Promise.all(systems.map(async (system) => {
await loader.repository.addOrUpdateSystem(system);
await loader.repository.updateSystem(system);
}));
await loader.fetchAndUpdateEtaDataForExistingStopsForSystemsInRepository();

View File

@@ -24,7 +24,7 @@ describe("UnoptimizedInMemoryRepository", () => {
describe("getSystems", () => {
test("gets the system stored in the repository", async () => {
const mockSystems = generateMockSystems();
await repository.addOrUpdateSystem(mockSystems[0]);
await repository.updateSystem(mockSystems[0]);
const result = await repository.getSystemIfExists();
@@ -42,7 +42,7 @@ describe("UnoptimizedInMemoryRepository", () => {
test("gets a system by the ID if it exists", async () => {
const mockSystems = generateMockSystems();
for (const system of mockSystems) {
await repository.addOrUpdateSystem(system);
await repository.updateSystem(system);
}
const result = await repository.getSystemById("2");
@@ -327,7 +327,7 @@ describe("UnoptimizedInMemoryRepository", () => {
const mockSystems = generateMockSystems();
const newSystem = mockSystems[0];
await repository.addOrUpdateSystem(newSystem);
await repository.updateSystem(newSystem);
const result = await repository.getSystemIfExists();
expect(result).toEqual([newSystem]);
@@ -339,8 +339,8 @@ describe("UnoptimizedInMemoryRepository", () => {
const updatedSystem = structuredClone(existingSystem);
updatedSystem.name = "Updated System";
await repository.addOrUpdateSystem(existingSystem);
await repository.addOrUpdateSystem(updatedSystem);
await repository.updateSystem(existingSystem);
await repository.updateSystem(updatedSystem);
const result = await repository.getSystemIfExists();
expect(result).toEqual([updatedSystem]);
@@ -476,7 +476,7 @@ describe("UnoptimizedInMemoryRepository", () => {
test("removes system given ID", async () => {
const mockSystems = generateMockSystems();
await Promise.all(mockSystems.map(async (system) => {
await repository.addOrUpdateSystem(system);
await repository.updateSystem(system);
}));
const systemToRemove = mockSystems[0];
@@ -489,7 +489,7 @@ describe("UnoptimizedInMemoryRepository", () => {
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.updateSystem(system);
}));
await repository.removeSystemIfExists("nonexistent-id");
@@ -664,7 +664,7 @@ describe("UnoptimizedInMemoryRepository", () => {
test("clears all systems from the repository", async () => {
const mockSystems = generateMockSystems();
for (const system of mockSystems) {
await repository.addOrUpdateSystem(system);
await repository.updateSystem(system);
}
await repository.clearSystemData();
@@ -676,7 +676,7 @@ describe("UnoptimizedInMemoryRepository", () => {
test("clears system data when the repository has data", async () => {
const mockSystems = generateMockSystems();
const system = mockSystems[0];
await repository.addOrUpdateSystem(system);
await repository.updateSystem(system);
await repository.clearSystemData();

View File

@@ -15,7 +15,7 @@ describe("QueryResolvers", () => {
async function addMockSystems() {
const systems = generateMockSystems();
await Promise.all(systems.map(async (system) => {
await context.shuttleRepository.addOrUpdateSystem(system);
await context.shuttleRepository.updateSystem(system);
}));
return systems;
}

View File

@@ -133,7 +133,7 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.addOrUpdateSystem(updatedSystem);
await context.shuttleRepository.updateSystem(updatedSystem);
const mockStop = await addMockStopToRepository(context.shuttleRepository, updatedSystem.id);
@@ -199,7 +199,7 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.addOrUpdateSystem(updatedSystem);
await context.shuttleRepository.updateSystem(updatedSystem);
const mockRoute = await addMockRouteToRepository(context.shuttleRepository, updatedSystem.id);
@@ -265,7 +265,7 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.addOrUpdateSystem(updatedSystem);
await context.shuttleRepository.updateSystem(updatedSystem);
const mockShuttle = await addMockShuttleToRepository(context.shuttleRepository, updatedSystem.id);

View File

@@ -11,7 +11,7 @@ export async function addMockSystemToRepository(repository: ShuttleGetterSetterR
const mockSystems = generateMockSystems();
const mockSystem = mockSystems[0];
mockSystem.id = "1";
await repository.addOrUpdateSystem(mockSystem);
await repository.updateSystem(mockSystem);
return mockSystem;
}