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

@@ -4,7 +4,6 @@ import { IEta, IShuttle, IStop, IPassioSystem } from "../../src/entities/entitie
import {
addMockEtaToRepository, addMockShuttleToRepository,
addMockStopToRepository,
addMockSystemToRepository
} from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
@@ -12,23 +11,21 @@ describe("EtaResolvers", () => {
const holder = setupTestServerHolder();
const context = setupTestServerContext();
let mockSystem: IPassioSystem;
let mockShuttle: IShuttle;
let mockStop: IStop;
let expectedEta: IEta;
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockShuttle = await addMockShuttleToRepository(context.shuttleRepository, mockSystem.id);
mockStop = await addMockStopToRepository(context.shuttleRepository, mockSystem.id);
expectedEta = await addMockEtaToRepository(context.shuttleRepository, mockStop.id, mockShuttle.id);
mockShuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, context.systems[0].id);
mockStop = await addMockStopToRepository(context.systems[0].shuttleRepository, context.systems[0].id);
expectedEta = await addMockEtaToRepository(context.systems[0].shuttleRepository, mockStop.id, mockShuttle.id);
});
async function getResponseForEtaQuery(query: string) {
const response = await holder.testServer.executeOperation({
query,
variables: {
systemId: mockSystem.id,
systemId: context.systems[0].id,
shuttleId: mockShuttle.id,
},
}, {

View File

@@ -3,7 +3,6 @@ import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/ap
import {
addMockShuttleToRepository,
addMockStopToRepository,
addMockSystemToRepository
} from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
import { NotificationInput } from "../../src/generated/graphql";
@@ -44,14 +43,14 @@ describe("MutationResolvers", () => {
const notificationResponse = response.body.singleResult.data?.scheduleNotification as any;
expect(notificationResponse.success).toBe(false);
expect(await context.notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
expect(await context.systems[0].notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
}
it("adds a notification to the notification service", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -72,13 +71,13 @@ describe("MutationResolvers", () => {
expect(notificationResponse?.success).toBe(true);
expect(notificationResponse?.data).toEqual(expectedNotificationData);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(expectedNotificationData)).toBe(240);
expect(await context.systems[0].notificationRepository.getSecondsThresholdForNotificationIfExists(expectedNotificationData)).toBe(240);
});
it("adds a notification with the default seconds threshold if none is provided", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -93,12 +92,12 @@ describe("MutationResolvers", () => {
const notificationResponse = response.body.singleResult.data?.scheduleNotification as any;
expect(notificationResponse?.success).toBe(true);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(notificationInput)).toBe(180);
expect(await context.systems[0].notificationRepository.getSecondsThresholdForNotificationIfExists(notificationInput)).toBe(180);
});
it("fails if the shuttle ID doesn't exist", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -110,8 +109,8 @@ describe("MutationResolvers", () => {
});
it("fails if the stop ID doesn't exist", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -140,9 +139,9 @@ describe("MutationResolvers", () => {
`
it("removes the notification from the notification service", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput: any = {
deviceId: "1",
@@ -150,7 +149,7 @@ describe("MutationResolvers", () => {
stopId: stop.id,
secondsThreshold: 180,
}
await context.notificationRepository.addOrUpdateNotification(notificationInput);
await context.systems[0].notificationRepository.addOrUpdateNotification(notificationInput);
const notificationLookup = {
...notificationInput
@@ -166,7 +165,7 @@ describe("MutationResolvers", () => {
expect(notificationResponse.success).toBe(true);
expect(notificationResponse.data).toEqual(notificationLookup);
expect(await context.notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
expect(await context.systems[0].notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
});
it("fails if the notification doesn't exist", async () => {

View File

@@ -2,25 +2,23 @@ import { beforeEach, describe, expect, it } from "@jest/globals";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import { IRoute, IStop, IPassioSystem } from "../../src/entities/entities";
import { generateMockOrderedStops, generateMockStops } from "../testHelpers/mockDataGenerators";
import { addMockRouteToRepository, addMockSystemToRepository } from "../testHelpers/repositorySetupHelpers";
import { addMockRouteToRepository } from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
describe("OrderedStopResolvers", () => {
const holder = setupTestServerHolder();
const context = setupTestServerContext();
let mockSystem: IPassioSystem;
let mockRoute: IRoute;
let mockStops: IStop[];
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockRoute = await addMockRouteToRepository(context.shuttleRepository, mockSystem.id);
mockRoute = await addMockRouteToRepository(context.systems[0].shuttleRepository, context.systems[0].id);
mockStops = generateMockStops();
await Promise.all(mockStops.map(async (mockStop) => {
mockStop.systemId = mockSystem.id;
await context.shuttleRepository.addOrUpdateStop(mockStop);
mockStop.systemId = context.systems[0].id;
await context.systems[0].shuttleRepository.addOrUpdateStop(mockStop);
}));
});
@@ -38,8 +36,8 @@ describe("OrderedStopResolvers", () => {
// Link the stops together
orderedStops[0].nextStop = orderedStops[1];
orderedStops[1].previousStop = orderedStops[0];
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[1]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[1]);
return orderedStops;
}
@@ -63,7 +61,7 @@ describe("OrderedStopResolvers", () => {
return await holder.testServer.executeOperation({
query,
variables: {
systemId: mockSystem.id,
systemId: context.systems[0].id,
routeId: mockRoute.id,
stopId,
},
@@ -93,7 +91,7 @@ describe("OrderedStopResolvers", () => {
it("returns null if there is no next stop in the repository", async () => {
const orderedStops = await setUpOrderedStopsInRepository();
orderedStops[0].nextStop = undefined;
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
const response = await getResponseForNextStopQuery(orderedStops[0].stopId);
@@ -104,7 +102,7 @@ describe("OrderedStopResolvers", () => {
it("returns null if the next stop object no longer exists", async () => {
const orderedStops = await setUpOrderedStopsInRepository();
await context.shuttleRepository.removeStopIfExists(orderedStops[1].stopId);
await context.systems[0].shuttleRepository.removeStopIfExists(orderedStops[1].stopId);
const response = await getResponseForNextStopQuery(orderedStops[0].stopId);
@@ -134,7 +132,7 @@ describe("OrderedStopResolvers", () => {
return await holder.testServer.executeOperation({
query,
variables: {
systemId: mockSystem.id,
systemId: context.systems[0].id,
routeId: mockRoute.id,
stopId,
},
@@ -163,7 +161,7 @@ describe("OrderedStopResolvers", () => {
it("returns null if there is no previous stop in the repository", async () => {
const orderedStops = await setUpOrderedStopsInRepository();
orderedStops[1].previousStop = undefined;
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[1]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[1]);
const response = await getResponseForPreviousStopQuery(orderedStops[1].stopId);
@@ -174,7 +172,7 @@ describe("OrderedStopResolvers", () => {
it("returns null if the current stop no longer exists", async () => {
const orderedStops = await setUpOrderedStopsInRepository();
await context.shuttleRepository.removeStopIfExists(orderedStops[0].stopId);
await context.systems[0].shuttleRepository.removeStopIfExists(orderedStops[0].stopId);
const response = await getResponseForPreviousStopQuery(orderedStops[1].stopId);
@@ -208,7 +206,7 @@ describe("OrderedStopResolvers", () => {
return await holder.testServer.executeOperation({
query,
variables: {
systemId: mockSystem.id,
systemId: context.systems[0].id,
stopId,
}
}, {
@@ -223,7 +221,7 @@ describe("OrderedStopResolvers", () => {
orderedStops[0].stopId = mockStops[0].id;
// Add one stop only
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
const response = await getResponseForRouteQuery(orderedStops[1].stopId);
@@ -257,7 +255,7 @@ describe("OrderedStopResolvers", () => {
return await holder.testServer.executeOperation({
query,
variables: {
systemId: mockSystem.id,
systemId: context.systems[0].id,
routeId: mockRoute.id,
stopId,
}
@@ -270,7 +268,7 @@ describe("OrderedStopResolvers", () => {
it("returns the associated stop if it exists", async () => {
const orderedStops = await setUpOrderedStopsInRepository();
orderedStops[0].stopId = mockStops[0].id;
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStops[0]);
const response = await getResponseForStopQuery(orderedStops[0].stopId);

View File

@@ -12,17 +12,9 @@ describe("QueryResolvers", () => {
const holder = setupTestServerHolder();
const context = setupTestServerContext();
async function addMockSystems() {
const systems = generateMockPassioSystems();
await Promise.all(systems.map(async (system) => {
await context.shuttleRepository.updateSystem(system);
}));
return systems;
}
describe("systems", () => {
it("returns systems from the repository", async () => {
const systems = await addMockSystems();
const systems = context.systems;
const query = `
query GetSystems
@@ -58,7 +50,7 @@ describe("QueryResolvers", () => {
`;
it("returns a system for an ID from the repository", async () => {
const systems = await addMockSystems();
const systems = context.systems;
const systemToGet = systems[1];
const response = await holder.testServer.executeOperation({
@@ -103,8 +95,8 @@ describe("QueryResolvers", () => {
it("returns correct data if the notification is scheduled", async () => {
// Arrange
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, "1");
const stop = await addMockStopToRepository(context.shuttleRepository, "1")
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, "1");
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, "1")
const notification: ScheduledNotification = {
shuttleId: shuttle.id,
@@ -112,7 +104,7 @@ describe("QueryResolvers", () => {
deviceId: "1",
secondsThreshold: 240,
};
await context.notificationRepository.addOrUpdateNotification(notification);
await context.systems[0].notificationRepository.addOrUpdateNotification(notification);
const notificationLookup: any = {
...notification,

View File

@@ -2,8 +2,7 @@ import { beforeEach, describe, expect, it } from "@jest/globals";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import {
addMockRouteToRepository,
addMockStopToRepository,
addMockSystemToRepository
addMockStopToRepository
} from "../testHelpers/repositorySetupHelpers";
import { generateMockOrderedStops, generateMockShuttles } from "../testHelpers/mockDataGenerators";
import { IRoute, IStop, IPassioSystem } from "../../src/entities/entities";
@@ -18,11 +17,11 @@ describe("RouteResolvers", () => {
let mockStop: IStop;
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockSystem = context.systems[0];
const systemId = mockSystem.id;
mockRoute = await addMockRouteToRepository(context.shuttleRepository, systemId);
mockStop = await addMockStopToRepository(context.shuttleRepository, systemId);
mockRoute = await addMockRouteToRepository(context.systems[0].shuttleRepository, systemId);
mockStop = await addMockStopToRepository(context.systems[0].shuttleRepository, systemId);
});
@@ -58,7 +57,7 @@ describe("RouteResolvers", () => {
const expectedShuttle = expectedShuttles[0];
expectedShuttle.systemId = mockSystem.id;
expectedShuttle.routeId = mockRoute.id;
await context.shuttleRepository.addOrUpdateShuttle(expectedShuttle);
await context.systems[0].shuttleRepository.addOrUpdateShuttle(expectedShuttle);
const response = await getResponseForShuttlesQuery();
@@ -113,7 +112,7 @@ describe("RouteResolvers", () => {
const expectedOrderedStop = orderedStops[0];
expectedOrderedStop.stopId = mockStop.id;
expectedOrderedStop.routeId = mockRoute.id;
await context.shuttleRepository.addOrUpdateOrderedStop(expectedOrderedStop);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(expectedOrderedStop);
const response = await getResponseForOrderedStopQuery();
@@ -130,9 +129,9 @@ describe("RouteResolvers", () => {
const expectedOrderedStop = orderedStops[0];
expectedOrderedStop.stopId = mockStop.id;
expectedOrderedStop.routeId = mockRoute.id;
await context.shuttleRepository.addOrUpdateOrderedStop(expectedOrderedStop);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(expectedOrderedStop);
await context.shuttleRepository.removeStopIfExists(mockStop.id);
await context.systems[0].shuttleRepository.removeStopIfExists(mockStop.id);
const response = await getResponseForOrderedStopQuery();

View File

@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it } from "@jest/globals";
import { generateMockEtas, generateMockRoutes } from "../testHelpers/mockDataGenerators";
import { IShuttle, IPassioSystem } from "../../src/entities/entities";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import { addMockShuttleToRepository, addMockSystemToRepository } from "../testHelpers/repositorySetupHelpers";
import { addMockShuttleToRepository } from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
@@ -14,8 +14,8 @@ describe("ShuttleResolvers", () => {
let mockShuttle: IShuttle;
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockShuttle = await addMockShuttleToRepository(context.shuttleRepository,
mockSystem = context.systems[0];
mockShuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository,
mockSystem.id);
});
@@ -24,7 +24,7 @@ describe("ShuttleResolvers", () => {
const etas = generateMockEtas();
await Promise.all(etas.map(async (eta) => {
eta.shuttleId = shuttleId;
await context.shuttleRepository.addOrUpdateEta(eta);
await context.systems[0].shuttleRepository.addOrUpdateEta(eta);
}));
return etas;
}
@@ -175,7 +175,7 @@ describe("ShuttleResolvers", () => {
it("returns the route if it exists", async () => {
const mockRoute = generateMockRoutes()[0];
await context.shuttleRepository.addOrUpdateRoute(mockRoute);
await context.systems[0].shuttleRepository.addOrUpdateRoute(mockRoute);
const response = await getResponseForQuery();

View File

@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it } from "@jest/globals";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import { generateMockEtas, generateMockOrderedStops } from "../testHelpers/mockDataGenerators";
import { IStop, IPassioSystem } from "../../src/entities/entities";
import { addMockStopToRepository, addMockSystemToRepository } from "../testHelpers/repositorySetupHelpers";
import { addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
describe("StopResolvers", () => {
@@ -13,8 +13,8 @@ describe("StopResolvers", () => {
let mockSystem: IPassioSystem;
beforeEach(async () => {
mockSystem = await addMockSystemToRepository(context.shuttleRepository);
mockStop = await addMockStopToRepository(context.shuttleRepository, mockSystem.id);
mockSystem = context.systems[0];
mockStop = await addMockStopToRepository(context.systems[0].shuttleRepository, mockSystem.id);
})
async function getResponseForQuery(query: string) {
@@ -49,7 +49,7 @@ describe("StopResolvers", () => {
mockOrderedStops = mockOrderedStops.filter((orderedStop) => orderedStop.stopId === mockOrderedStops[0].stopId);
await Promise.all(mockOrderedStops.map(async orderedStop => {
orderedStop.stopId = mockStop.id;
await context.shuttleRepository.addOrUpdateOrderedStop(orderedStop);
await context.systems[0].shuttleRepository.addOrUpdateOrderedStop(orderedStop);
}));
const response = await getResponseForQuery(query);
@@ -86,7 +86,7 @@ describe("StopResolvers", () => {
mockEtas = mockEtas.filter((eta) => eta.stopId === mockEtas[0].stopId);
await Promise.all(mockEtas.map(async eta => {
eta.stopId = mockStop.id;
await context.shuttleRepository.addOrUpdateEta(eta);
await context.systems[0].shuttleRepository.addOrUpdateEta(eta);
}));
const response = await getResponseForQuery(query);

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);

View File

@@ -3,19 +3,9 @@ import {
generateMockRoutes,
generateMockShuttles,
generateMockStops,
generateMockPassioSystems
} from "./mockDataGenerators";
import { ShuttleGetterSetterRepository } from "../../src/repositories/ShuttleGetterSetterRepository";
export async function addMockSystemToRepository(repository: ShuttleGetterSetterRepository) {
const mockSystems = generateMockPassioSystems();
const mockSystem = mockSystems[0];
mockSystem.id = "1";
await repository.updateSystem(mockSystem);
return mockSystem;
}
export async function addMockRouteToRepository(repository: ShuttleGetterSetterRepository, systemId: string) {
const mockRoutes = generateMockRoutes();
const mockRoute = mockRoutes[0];