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,10 +444,7 @@ 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 repository = new ApiBasedRepository(); const sampleStop: IStop = {
repository.getStopsBySystemId = jest.fn(async () => {
return [
{
name: "Chapman Court", name: "Chapman Court",
systemId: "1", systemId: "1",
id: "177666", id: "177666",
@@ -456,9 +453,18 @@ describe("updateEtasForSystemIfTTL", () => {
longitude: -117.889293 longitude: -117.889293
}, },
} }
const repository = new ApiBasedRepository();
repository.getStopsBySystemId = jest.fn(async () => {
return [
sampleStop
]; ];
}); });
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");