add test case for successful shuttle data fetch

This commit is contained in:
2025-01-22 15:45:23 -08:00
parent eb5d872a1e
commit 40231adfec

View File

@@ -9,6 +9,9 @@ import {
} from "../jsonSnapshots/fetchStopAndPolylineData/fetchStopAndPolylineDataSuccessfulResponse";
import { generateMockStops, generateMockSystems } from "../generators";
import { IStop } from "../../src/entities/entities";
import {
fetchShuttleDataSuccessfulResponse
} from "../jsonSnapshots/fetchShuttleData/fetchShuttleDataSuccessfulResponse";
/**
* Function to update behavior of the global `fetch` function.
@@ -197,7 +200,14 @@ describe("ApiBasedRepositoryLoader", () => {
describe("fetchAndUpdateShuttleDataForSystemId", () => {
it("updates shuttle data in repository if response received", async () => {
updateGlobalFetchMockJson(fetchShuttleDataSuccessfulResponse);
const busesInResponse = Object.values(fetchShuttleDataSuccessfulResponse.buses);
await loader.fetchAndUpdateShuttleDataForSystemId("263");
const shuttles = await loader.repository.getShuttlesBySystemId("263");
expect(shuttles.length).toEqual(busesInResponse.length);
});
it("throws the correct error if the API response contains no data", async () => {