add test for ChapmanApiBasedParkingRepositoryLoader.fetchAndUpdateAll

This commit is contained in:
2025-04-11 17:09:52 -07:00
parent 50350d8c49
commit 0e3c12bebc

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it } from "@jest/globals"; import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import { import {
ChapmanApiBasedParkingRepositoryLoader ChapmanApiBasedParkingRepositoryLoader
} from "../../../src/loaders/ParkingRepositoryLoaders/ChapmanApiBasedParkingRepositoryLoader"; } from "../../../src/loaders/ParkingRepositoryLoaders/ChapmanApiBasedParkingRepositoryLoader";
@@ -24,6 +24,26 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => {
resetGlobalFetchMockJson(); resetGlobalFetchMockJson();
}); });
describe("fetchAndUpdateAll", () => {
it("calls all the correct methods", async () => {
const spies = {
fetchAndUpdateParkingStructures: jest.spyOn(loader, "fetchAndUpdateParkingStructures"),
};
Object.values(spies).forEach((spy: any) => {
spy.mockResolvedValue(undefined);
});
await loader.fetchAndUpdateAll();
Object.values(spies).forEach((spy: any) => {
expect(spy).toHaveBeenCalled();
});
});
});
describe("fetchAndUpdateParkingStructures", () => { describe("fetchAndUpdateParkingStructures", () => {
it("fetches and update parking structures with unique IDs", async () => { it("fetches and update parking structures with unique IDs", async () => {
updateGlobalFetchMockJson(chapmanParkingStructureData); updateGlobalFetchMockJson(chapmanParkingStructureData);