mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add pass to check validity of parking structures generated
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { beforeEach, describe, it } from "@jest/globals";
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import {
|
||||
ChapmanTimedApiBasedParkingRepositoryLoader
|
||||
} from "../../../src/loaders/ParkingRepositoryLoaders/ChapmanTimedApiBasedParkingRepositoryLoader";
|
||||
import { InMemoryParkingRepository } from "../../../src/repositories/InMemoryParkingRepository";
|
||||
import { resetGlobalFetchMockJson } from "../../testHelpers/fetchMockHelpers";
|
||||
import { resetGlobalFetchMockJson, updateGlobalFetchMockJson } from "../../testHelpers/fetchMockHelpers";
|
||||
import {
|
||||
chapmanParkingStructureData
|
||||
} from "../../jsonSnapshots/chapmanParkingStructureData/chapmanParkingStructureData";
|
||||
import { IParkingStructure } from "../../../src/entities/ParkingRepositoryEntities";
|
||||
|
||||
describe("ChapmanTimedApiBasedParkingRepositoryLoader", () => {
|
||||
let loader: ChapmanTimedApiBasedParkingRepositoryLoader;
|
||||
@@ -17,7 +21,39 @@ describe("ChapmanTimedApiBasedParkingRepositoryLoader", () => {
|
||||
|
||||
describe("fetchAndUpdateParkingStructures", () => {
|
||||
it("fetches and update parking structures with unique IDs", async () => {
|
||||
updateGlobalFetchMockJson(chapmanParkingStructureData);
|
||||
|
||||
await loader.fetchAndUpdateParkingStructures();
|
||||
|
||||
let expectedStructures: IParkingStructure[] = [
|
||||
{
|
||||
address: "300 E Walnut, Orange, CA 92867",
|
||||
capacity: 211,
|
||||
spotsAvailable: 871,
|
||||
coordinates: {
|
||||
latitude: 33.7945513,
|
||||
longitude: -117.8518707,
|
||||
},
|
||||
name: "Anderson Structure",
|
||||
id: "",
|
||||
},
|
||||
{
|
||||
address: "",
|
||||
capacity: 0,
|
||||
spotsAvailable: 0,
|
||||
coordinates: {
|
||||
latitude: 0,
|
||||
longitude: 0
|
||||
},
|
||||
name: "Barrera",
|
||||
id: "",
|
||||
}
|
||||
];
|
||||
expectedStructures[0].id = ChapmanTimedApiBasedParkingRepositoryLoader.generateId(expectedStructures[0].address);
|
||||
expectedStructures[1].id = ChapmanTimedApiBasedParkingRepositoryLoader.generateId(expectedStructures[1].address);
|
||||
|
||||
const structuresFromLoader = await loader.repository.getParkingStructures();
|
||||
expect(structuresFromLoader).toEqual(expectedStructures);
|
||||
});
|
||||
|
||||
it("throws ApiResponseError if data is incorrect", async () => {
|
||||
|
||||
Reference in New Issue
Block a user