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,
ApiBasedRepositoryMillisecondTTLs
} 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.
@@ -444,21 +444,27 @@ describe("updateEtasForSystemIfTTL", () => {
test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => {
updateGlobalFetchMockJson(genericEtaDataByStopId);
const sampleStop: IStop = {
name: "Chapman Court",
systemId: "1",
id: "177666",
coordinates: {
latitude: 33.796796,
longitude: -117.889293
},
}
const repository = new ApiBasedRepository();
repository.getStopsBySystemId = jest.fn(async () => {
return [
{
name: "Chapman Court",
systemId: "1",
id: "177666",
coordinates: {
latitude: 33.796796,
longitude: -117.889293
},
}
sampleStop
];
});
repository.getStopById = jest.fn(async () => {
return sampleStop;
});
await repository.updateEtasForSystemIfTTL("1");
const updatedResult = await repository.getEtasForStopId("177666");