From 9d5d499fb684375dd4dd6bcd04eabfb4aa4949d5 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Wed, 8 Jan 2025 17:17:29 -0800 Subject: [PATCH] stub out getStopById in test for updateEtasForSystemIfTTL --- .../ApiBasedRepositoryTests.test.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/repositories/ApiBasedRepositoryTests.test.ts b/test/repositories/ApiBasedRepositoryTests.test.ts index 699c17d..637723b 100644 --- a/test/repositories/ApiBasedRepositoryTests.test.ts +++ b/test/repositories/ApiBasedRepositoryTests.test.ts @@ -4,7 +4,7 @@ import { ApiBasedRepositoryCache, ApiBasedRepositoryMillisecondTTLs } from "../../src/repositories/ApiBasedRepository"; -import { IEta, IShuttle } from "../../src/entities/entities"; +import { IEta, IShuttle, IStop } from "../../src/entities/entities"; /** * Update the global fetch function to return a specific object. @@ -444,21 +444,27 @@ describe("updateEtasForSystemIfTTL", () => { test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => { updateGlobalFetchMockJson(genericEtaDataByStopId); + const sampleStop: IStop = { + name: "Chapman Court", + systemId: "1", + id: "177666", + coordinates: { + latitude: 33.796796, + longitude: -117.889293 + }, + } + const repository = new ApiBasedRepository(); repository.getStopsBySystemId = jest.fn(async () => { return [ - { - name: "Chapman Court", - systemId: "1", - id: "177666", - coordinates: { - latitude: 33.796796, - longitude: -117.889293 - }, - } + sampleStop ]; }); + repository.getStopById = jest.fn(async () => { + return sampleStop; + }); + await repository.updateEtasForSystemIfTTL("1"); const updatedResult = await repository.getEtasForStopId("177666");