mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add test for ApiResponseError
This commit is contained in:
@@ -3,11 +3,16 @@ import {
|
|||||||
ChapmanTimedApiBasedParkingRepositoryLoader
|
ChapmanTimedApiBasedParkingRepositoryLoader
|
||||||
} from "../../../src/loaders/ParkingRepositoryLoaders/ChapmanTimedApiBasedParkingRepositoryLoader";
|
} from "../../../src/loaders/ParkingRepositoryLoaders/ChapmanTimedApiBasedParkingRepositoryLoader";
|
||||||
import { InMemoryParkingRepository } from "../../../src/repositories/InMemoryParkingRepository";
|
import { InMemoryParkingRepository } from "../../../src/repositories/InMemoryParkingRepository";
|
||||||
import { resetGlobalFetchMockJson, updateGlobalFetchMockJson } from "../../testHelpers/fetchMockHelpers";
|
import {
|
||||||
|
resetGlobalFetchMockJson,
|
||||||
|
updateGlobalFetchMockJson,
|
||||||
|
updateGlobalFetchMockJsonToThrowSyntaxError
|
||||||
|
} from "../../testHelpers/fetchMockHelpers";
|
||||||
import {
|
import {
|
||||||
chapmanParkingStructureData
|
chapmanParkingStructureData
|
||||||
} from "../../jsonSnapshots/chapmanParkingStructureData/chapmanParkingStructureData";
|
} from "../../jsonSnapshots/chapmanParkingStructureData/chapmanParkingStructureData";
|
||||||
import { IParkingStructure } from "../../../src/entities/ParkingRepositoryEntities";
|
import { IParkingStructure } from "../../../src/entities/ParkingRepositoryEntities";
|
||||||
|
import { assertAsyncCallbackThrowsApiResponseError } from "../../testHelpers/assertAsyncCallbackThrowsApiResponseError";
|
||||||
|
|
||||||
describe("ChapmanTimedApiBasedParkingRepositoryLoader", () => {
|
describe("ChapmanTimedApiBasedParkingRepositoryLoader", () => {
|
||||||
let loader: ChapmanTimedApiBasedParkingRepositoryLoader;
|
let loader: ChapmanTimedApiBasedParkingRepositoryLoader;
|
||||||
@@ -57,7 +62,11 @@ describe("ChapmanTimedApiBasedParkingRepositoryLoader", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws ApiResponseError if data is incorrect", async () => {
|
it("throws ApiResponseError if data is incorrect", async () => {
|
||||||
|
updateGlobalFetchMockJsonToThrowSyntaxError();
|
||||||
|
|
||||||
|
await assertAsyncCallbackThrowsApiResponseError(async () => {
|
||||||
|
await loader.fetchAndUpdateParkingStructures();
|
||||||
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user