add test case for successful eta data response

This commit is contained in:
2025-01-22 15:49:47 -08:00
parent 05c03aa61f
commit 8e944892cc

View File

@@ -12,6 +12,7 @@ import { IStop } from "../../src/entities/entities";
import { import {
fetchShuttleDataSuccessfulResponse fetchShuttleDataSuccessfulResponse
} from "../jsonSnapshots/fetchShuttleData/fetchShuttleDataSuccessfulResponse"; } from "../jsonSnapshots/fetchShuttleData/fetchShuttleDataSuccessfulResponse";
import { fetchEtaDataSuccessfulResponse } from "../jsonSnapshots/fetchEtaData/fetchEtaDataSuccessfulResponse";
/** /**
* Function to update behavior of the global `fetch` function. * Function to update behavior of the global `fetch` function.
@@ -255,7 +256,15 @@ describe("ApiBasedRepositoryLoader", () => {
describe("fetchAndUpdateEtaDataForStopId", () => { describe("fetchAndUpdateEtaDataForStopId", () => {
it("updates ETA data for stop id if response received", async () => { it("updates ETA data for stop id if response received", async () => {
updateGlobalFetchMockJson(fetchEtaDataSuccessfulResponse);
const stopId = "177666";
// @ts-ignore
const etasFromResponse = fetchEtaDataSuccessfulResponse.ETAs[stopId]
await loader.fetchAndUpdateEtaDataForStopId(stopId);
const etas = await loader.repository.getEtasForStopId(stopId);
expect(etas.length).toEqual(etasFromResponse.length);
}); });
it("throws the correct error if the API response contains no data", async () => { it("throws the correct error if the API response contains no data", async () => {