From e9864da680f282df8fe499d5b95667b206b34133 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 7 Jan 2025 16:10:50 -0800 Subject: [PATCH] add tests for getEtasForShuttleId --- .../ApiBasedRepositoryTests.test.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/repositories/ApiBasedRepositoryTests.test.ts b/test/repositories/ApiBasedRepositoryTests.test.ts index 1e353ed..7eba7bb 100644 --- a/test/repositories/ApiBasedRepositoryTests.test.ts +++ b/test/repositories/ApiBasedRepositoryTests.test.ts @@ -254,16 +254,9 @@ describe("getEtaForShuttleAndStopId", () => { describe("getEtasForShuttleId", () => { test("getEtasForShuttleId returns correct ETA data", async () => { - // Because I'm testing updateEtasForSystemIfTTL separately, force it to hit - // the cache for the stops + // Because I'm testing updateEtasForSystemIfTTL separately, + // 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); const initialCache: ApiBasedRepositoryCache = { @@ -286,10 +279,21 @@ describe("getEtasForShuttleId", () => { }; const repository = new ApiBasedRepository(initialCache, ttls); + repository.updateEtasForSystemIfTTL = jest.fn(async () => { + }); const result = await repository.getEtasForShuttleId("5577"); 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", () => {