add test for getting parking structures associated with id

This commit is contained in:
2025-04-16 16:35:32 -07:00
parent 37a67aace7
commit ea1150a98d
2 changed files with 35 additions and 5 deletions

View File

@@ -1,6 +1,11 @@
import { beforeEach, describe, expect, it } from "@jest/globals";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import { generateMockRoutes, generateMockShuttles, generateMockStops } from "../testHelpers/mockDataGenerators";
import {
generateMockRoutes,
generateMockShuttles,
generateMockStops,
generateParkingStructures
} from "../testHelpers/mockDataGenerators";
import {
addMockRouteToRepository,
addMockShuttleToRepository,
@@ -310,8 +315,36 @@ describe("SystemResolvers", () => {
});
describe("parkingStructures", () => {
it("gets parking structures associated with the system id", async () => {
const query = `
query GetParkingStructuresBySystem($systemId: ID!) {
system(id: $systemId) {
parkingStructures {
name
id
capacity
spotsAvailable
coordinates {
latitude
longitude
}
address
}
}
}
`
it("gets parking structures associated with the system id", async () => {
const expectedParkingStructures = generateParkingStructures();
await Promise.all(expectedParkingStructures.map(async (structure) => {
await context.systems[0].parkingRepository?.addOrUpdateParkingStructure(structure);
}));
const response = await getResponseFromQueryNeedingSystemId(query);
assert(response.body.kind === "single");
expect(response.body.singleResult.errors).toBeUndefined();
const parkingStructures = (response.body.singleResult.data as any).parkingStructures;
expect(parkingStructures).toEqual(expectedParkingStructures);
});
it("returns a blank array if there are no parking structures", async () => {

View File

@@ -1,11 +1,8 @@
import { readFileSync } from "fs";
import { ApolloServer } from "@apollo/server";
import { MergedResolvers } from "../../src/MergedResolvers";
import { UnoptimizedInMemoryShuttleRepository } from "../../src/repositories/UnoptimizedInMemoryShuttleRepository";
import { beforeEach } from "@jest/globals";
import { ServerContext } from "../../src/ServerContext";
import { ETANotificationScheduler } from "../../src/notifications/schedulers/ETANotificationScheduler";
import { InMemoryNotificationRepository } from "../../src/repositories/InMemoryNotificationRepository";
import { InterchangeSystem } from "../../src/entities/InterchangeSystem";
import {
ChapmanApiBasedParkingRepositoryLoader