add getStopById test for getEtasForStopId

This commit is contained in:
2025-01-08 17:26:05 -08:00
parent 365031384c
commit f865544e49
2 changed files with 15 additions and 1 deletions

View File

@@ -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 = {};

View File

@@ -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 () => {