diff --git a/src/repositories/ApiBasedRepository.ts b/src/repositories/ApiBasedRepository.ts index 3876eef..93d0620 100644 --- a/src/repositories/ApiBasedRepository.ts +++ b/src/repositories/ApiBasedRepository.ts @@ -144,6 +144,8 @@ export class ApiBasedRepository implements GetterRepository { } this.cache.etasForStopId[stop.id] = []; + // This is technically incorrect, the entire shuttle cache + // should not be reset like this // TODO: restore normal cache behavior this.cache.etasForShuttleId = {}; diff --git a/test/repositories/ApiBasedRepositoryTests.test.ts b/test/repositories/ApiBasedRepositoryTests.test.ts index 17e800b..7e49127 100644 --- a/test/repositories/ApiBasedRepositoryTests.test.ts +++ b/test/repositories/ApiBasedRepositoryTests.test.ts @@ -384,11 +384,23 @@ describe("getEtasForStopId", () => { }; const repository = new ApiBasedRepository(initialCache, ttls); + repository.getStopById = jest.fn(async () => { + const stop: IStop = { + name: "Chapman Court", + systemId: "1", + id: "177666", + coordinates: { + latitude: 33.796796, + longitude: -117.889293 + }, + }; + return stop; + }); repository.updateEtasForSystemIfTTL = jest.fn(async () => { }); const result = await repository.getEtasForStopId("177666"); - expect(result).toEqual(initialCache.etasForShuttleId); + expect(result).toEqual(initialCache.etasForStopId!["177666"]); }); test("getEtasForStopId returns empty array if no data available", async () => {