mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add tests for getEtasForShuttleId
This commit is contained in:
@@ -254,16 +254,9 @@ describe("getEtaForShuttleAndStopId", () => {
|
|||||||
|
|
||||||
describe("getEtasForShuttleId", () => {
|
describe("getEtasForShuttleId", () => {
|
||||||
test("getEtasForShuttleId returns correct ETA data", async () => {
|
test("getEtasForShuttleId returns correct ETA data", async () => {
|
||||||
// Because I'm testing updateEtasForSystemIfTTL separately, force it to hit
|
// Because I'm testing updateEtasForSystemIfTTL separately,
|
||||||
// the cache for the stops
|
// stub it out here
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getEtasForShuttleId returns empty array if no data available", async () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getEtasForShuttleId returns old data if not expired", async () => {
|
|
||||||
updateGlobalFetchMockJson(genericEtaDataByStopId);
|
updateGlobalFetchMockJson(genericEtaDataByStopId);
|
||||||
|
|
||||||
const initialCache: ApiBasedRepositoryCache = {
|
const initialCache: ApiBasedRepositoryCache = {
|
||||||
@@ -286,10 +279,21 @@ describe("getEtasForShuttleId", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const repository = new ApiBasedRepository(initialCache, ttls);
|
const repository = new ApiBasedRepository(initialCache, ttls);
|
||||||
|
repository.updateEtasForSystemIfTTL = jest.fn(async () => {
|
||||||
|
});
|
||||||
const result = await repository.getEtasForShuttleId("5577");
|
const result = await repository.getEtasForShuttleId("5577");
|
||||||
|
|
||||||
expect(result).toEqual(initialCache.etasForShuttleId);
|
expect(result).toEqual(initialCache.etasForShuttleId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("getEtasForShuttleId returns empty array if no data available", async () => {
|
||||||
|
const repository = new ApiBasedRepository();
|
||||||
|
repository.updateEtasForSystemIfTTL = jest.fn(async () => {
|
||||||
|
});
|
||||||
|
const result = await repository.getEtasForShuttleId("5577");
|
||||||
|
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getEtasForStopId", () => {
|
describe("getEtasForStopId", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user