mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add test case for successful shuttle data fetch
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user