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 () => {