stub out getStopById in test for updateEtasForSystemIfTTL

This commit is contained in:
2025-01-08 17:17:29 -08:00
parent a4e359b19b
commit 9d5d499fb6

View File

@@ -4,7 +4,7 @@ import {
ApiBasedRepositoryCache, ApiBasedRepositoryCache,
ApiBasedRepositoryMillisecondTTLs ApiBasedRepositoryMillisecondTTLs
} from "../../src/repositories/ApiBasedRepository"; } from "../../src/repositories/ApiBasedRepository";
import { IEta, IShuttle } from "../../src/entities/entities"; import { IEta, IShuttle, IStop } from "../../src/entities/entities";
/** /**
* Update the global fetch function to return a specific object. * Update the global fetch function to return a specific object.
@@ -444,21 +444,27 @@ describe("updateEtasForSystemIfTTL", () => {
test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => { test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => {
updateGlobalFetchMockJson(genericEtaDataByStopId); updateGlobalFetchMockJson(genericEtaDataByStopId);
const sampleStop: IStop = {
name: "Chapman Court",
systemId: "1",
id: "177666",
coordinates: {
latitude: 33.796796,
longitude: -117.889293
},
}
const repository = new ApiBasedRepository(); const repository = new ApiBasedRepository();
repository.getStopsBySystemId = jest.fn(async () => { repository.getStopsBySystemId = jest.fn(async () => {
return [ return [
{ sampleStop
name: "Chapman Court",
systemId: "1",
id: "177666",
coordinates: {
latitude: 33.796796,
longitude: -117.889293
},
}
]; ];
}); });
repository.getStopById = jest.fn(async () => {
return sampleStop;
});
await repository.updateEtasForSystemIfTTL("1"); await repository.updateEtasForSystemIfTTL("1");
const updatedResult = await repository.getEtasForStopId("177666"); const updatedResult = await repository.getEtasForStopId("177666");