Files
project-inter-server/test/loaders/ApiBasedRepositoryLoaderTests.test.ts
2025-01-22 13:35:39 -08:00

81 lines
2.2 KiB
TypeScript

import { beforeEach, describe, it, jest, test } from "@jest/globals";
import { ApiBasedRepositoryLoader } from "../../src/loaders/ApiBasedRepositoryLoader";
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
function updateGlobalFetchMockJson(obj: any) {
// @ts-ignore
global.fetch = jest.fn(() => {
return Promise.resolve({
json: () => Promise.resolve(obj)
})
}) as jest.Mock;
}
/**
* Reset the global fetch function mock's JSON to return an empty object.
* @param obj
*/
function resetGlobalFetchMockJson() {
updateGlobalFetchMockJson({})
}
describe("ApiBasedRepositoryLoader", () => {
let loader: ApiBasedRepositoryLoader;
beforeEach(() => {
loader = new ApiBasedRepositoryLoader(new UnoptimizedInMemoryRepository());
resetGlobalFetchMockJson();
});
describe("fetchAndUpdateSystemData", () => {
it("updates system data in repository if response received", async () => {
});
it("throws the correct error if the API response contains no data", async () => {
});
});
describe("fetchAndUpdateRouteDataForExistingSystems", () => {
it("updates route data in repository if there are systems and response received", async () => {
});
it("throws the correct error if the API response contains no data", async () => {
});
});
describe("fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystems", () => {
it("updates stop and polyline data if there are systems and response received", async () => {
});
it("throws the correct error if the API response contains no data", async () => {
})
});
describe("fetchAndUpdateShuttleDataForExistingSystems", () => {
it("updates shuttle data in repository if there are systems and response received", async () => {
});
it("throws the correct error if the API response contains no data", async () => {
});
});
describe("fetchAndUpdateEtaDataForExistingSystems", () => {
it("updates shuttle data in repository if there are systems and response received", async () => {
});
it("throws the correct error if the API response contains no data", async () => {
});
});
});