mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add test for getting parking structures associated with id
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||||
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
|
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
|
||||||
import { generateMockRoutes, generateMockShuttles, generateMockStops } from "../testHelpers/mockDataGenerators";
|
import {
|
||||||
|
generateMockRoutes,
|
||||||
|
generateMockShuttles,
|
||||||
|
generateMockStops,
|
||||||
|
generateParkingStructures
|
||||||
|
} from "../testHelpers/mockDataGenerators";
|
||||||
import {
|
import {
|
||||||
addMockRouteToRepository,
|
addMockRouteToRepository,
|
||||||
addMockShuttleToRepository,
|
addMockShuttleToRepository,
|
||||||
@@ -310,8 +315,36 @@ describe("SystemResolvers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("parkingStructures", () => {
|
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 () => {
|
it("returns a blank array if there are no parking structures", async () => {
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { ApolloServer } from "@apollo/server";
|
import { ApolloServer } from "@apollo/server";
|
||||||
import { MergedResolvers } from "../../src/MergedResolvers";
|
import { MergedResolvers } from "../../src/MergedResolvers";
|
||||||
import { UnoptimizedInMemoryShuttleRepository } from "../../src/repositories/UnoptimizedInMemoryShuttleRepository";
|
|
||||||
import { beforeEach } from "@jest/globals";
|
import { beforeEach } from "@jest/globals";
|
||||||
import { ServerContext } from "../../src/ServerContext";
|
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 { InterchangeSystem } from "../../src/entities/InterchangeSystem";
|
||||||
import {
|
import {
|
||||||
ChapmanApiBasedParkingRepositoryLoader
|
ChapmanApiBasedParkingRepositoryLoader
|
||||||
|
|||||||
Reference in New Issue
Block a user