fix test references after removal of addMockSystemToRepository

This commit is contained in:
2025-04-07 12:07:32 -07:00
parent dbb56f207d
commit 9c414be8ce
9 changed files with 73 additions and 102 deletions

View File

@@ -5,7 +5,6 @@ import {
addMockRouteToRepository,
addMockShuttleToRepository,
addMockStopToRepository,
addMockSystemToRepository
} from "../testHelpers/repositorySetupHelpers";
import { IPassioSystem } from "../../src/entities/entities";
import assert = require("node:assert");
@@ -17,7 +16,7 @@ describe("SystemResolvers", () => {
let mockSystem: IPassioSystem;
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockSystem = context.systems[0];
});
// TODO: Consolidate these into one single method taking an object
@@ -29,7 +28,7 @@ describe("SystemResolvers", () => {
},
}, {
contextValue: {
shuttleRepository: context.shuttleRepository
shuttleRepository: context.systems[0].shuttleRepository,
},
});
}
@@ -50,7 +49,7 @@ describe("SystemResolvers", () => {
const expectedRoutes = generateMockRoutes();
await Promise.all(expectedRoutes.map(async (route) => {
route.systemId = mockSystem.id;
await context.shuttleRepository.addOrUpdateRoute(route);
await context.systems[0].shuttleRepository.addOrUpdateRoute(route);
}));
const response = await getResponseFromQueryNeedingSystemId(query);
@@ -78,7 +77,7 @@ describe("SystemResolvers", () => {
const expectedStops = generateMockStops();
await Promise.all(expectedStops.map(async (stop) => {
stop.systemId = mockSystem.id;
await context.shuttleRepository.addOrUpdateStop(stop);
await context.systems[0].shuttleRepository.addOrUpdateStop(stop);
}));
const response = await getResponseFromQueryNeedingSystemId(query);
@@ -111,13 +110,13 @@ describe("SystemResolvers", () => {
},
}, {
contextValue: {
shuttleRepository: context.shuttleRepository,
shuttleRepository: context.systems[0].shuttleRepository,
}
});
}
it("gets the stop with the correct id", async () => {
const mockStop = await addMockStopToRepository(context.shuttleRepository, mockSystem.id);
const mockStop = await addMockStopToRepository(context.systems[0].shuttleRepository, mockSystem.id);
const response = await getResponseForStopQuery(mockStop.id);
@@ -133,9 +132,8 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.updateSystem(updatedSystem);
const mockStop = await addMockStopToRepository(context.shuttleRepository, updatedSystem.id);
const mockStop = await addMockStopToRepository(context.systems[0].shuttleRepository, updatedSystem.id);
const response = await getResponseForStopQuery(mockStop.id);
@@ -182,7 +180,7 @@ describe("SystemResolvers", () => {
}
it("gets the route with the correct id", async () => {
const mockRoute = await addMockRouteToRepository(context.shuttleRepository, mockSystem.id);
const mockRoute = await addMockRouteToRepository(context.systems[0].shuttleRepository, mockSystem.id);
const response = await getResponseForRouteQuery(mockRoute.id);
@@ -199,9 +197,8 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.updateSystem(updatedSystem);
const mockRoute = await addMockRouteToRepository(context.shuttleRepository, updatedSystem.id);
const mockRoute = await addMockRouteToRepository(context.systems[0].shuttleRepository, updatedSystem.id);
const response = await getResponseForRouteQuery(mockRoute.id);
@@ -249,7 +246,7 @@ describe("SystemResolvers", () => {
}
it("gets the shuttle with the correct id", async () => {
const mockShuttle = await addMockShuttleToRepository(context.shuttleRepository, mockSystem.id);
const mockShuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, mockSystem.id);
const response = await getResponseForShuttleQuery(mockShuttle.id);
@@ -265,9 +262,8 @@ describe("SystemResolvers", () => {
...mockSystem,
id: "2",
}
await context.shuttleRepository.updateSystem(updatedSystem);
const mockShuttle = await addMockShuttleToRepository(context.shuttleRepository, updatedSystem.id);
const mockShuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, updatedSystem.id);
const response = await getResponseForShuttleQuery(mockShuttle.id);
@@ -305,7 +301,7 @@ describe("SystemResolvers", () => {
const expectedShuttles = generateMockShuttles();
await Promise.all(expectedShuttles.map(async (shuttle) => {
shuttle.systemId = mockSystem.id;
await context.shuttleRepository.addOrUpdateShuttle(shuttle);
await context.systems[0].shuttleRepository.addOrUpdateShuttle(shuttle);
}));
const response = await getResponseFromQueryNeedingSystemId(query);