mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
71 lines
1.4 KiB
TypeScript
71 lines
1.4 KiB
TypeScript
import { beforeEach, describe, jest, test } from "@jest/globals";
|
|
|
|
/**
|
|
* Update the global fetch function to return a specific object.
|
|
* @param obj
|
|
*/
|
|
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({})
|
|
}
|
|
|
|
beforeEach(() => {
|
|
resetGlobalFetchMockJson();
|
|
})
|
|
|
|
describe("getEtaForShuttleAndStopId", () => {
|
|
test("getEtaForShuttleAndStopId returns correct ETA data", async () => {
|
|
|
|
});
|
|
|
|
test("getEtaForShuttleAndStopId returns null if API call is invalid", async () => {
|
|
|
|
});
|
|
|
|
test("getEtasForShuttleAndStopId returns old data if not expired", async () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("getEtasForShuttleId", () => {
|
|
test("getEtasForShuttleId returns correct ETA data", async () => {
|
|
|
|
});
|
|
|
|
test("getEtasForShuttleId returns empty array if no data available", async () => {
|
|
|
|
});
|
|
|
|
test("getEtasForShuttleId returns old data if not expired", async () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("getEtasForStopId", () => {
|
|
test("getEtasForStopId returns correct ETA data", async () => {
|
|
|
|
});
|
|
|
|
test("getEtasForStopId returns empty array if no data available", async () => {
|
|
|
|
});
|
|
|
|
test("getEtasForStopId returns old data if not expired", async () => {
|
|
|
|
});
|
|
});
|
|
|
|
|