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 eta data response
This commit is contained in:
@@ -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 () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user