mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add getStopById test for getEtasForStopId
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user