mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
stub out getStopById in test for updateEtasForSystemIfTTL
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
|||||||
ApiBasedRepositoryCache,
|
ApiBasedRepositoryCache,
|
||||||
ApiBasedRepositoryMillisecondTTLs
|
ApiBasedRepositoryMillisecondTTLs
|
||||||
} from "../../src/repositories/ApiBasedRepository";
|
} 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.
|
* Update the global fetch function to return a specific object.
|
||||||
@@ -444,10 +444,7 @@ describe("updateEtasForSystemIfTTL", () => {
|
|||||||
test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => {
|
test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => {
|
||||||
updateGlobalFetchMockJson(genericEtaDataByStopId);
|
updateGlobalFetchMockJson(genericEtaDataByStopId);
|
||||||
|
|
||||||
const repository = new ApiBasedRepository();
|
const sampleStop: IStop = {
|
||||||
repository.getStopsBySystemId = jest.fn(async () => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
name: "Chapman Court",
|
name: "Chapman Court",
|
||||||
systemId: "1",
|
systemId: "1",
|
||||||
id: "177666",
|
id: "177666",
|
||||||
@@ -456,9 +453,18 @@ describe("updateEtasForSystemIfTTL", () => {
|
|||||||
longitude: -117.889293
|
longitude: -117.889293
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const repository = new ApiBasedRepository();
|
||||||
|
repository.getStopsBySystemId = jest.fn(async () => {
|
||||||
|
return [
|
||||||
|
sampleStop
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repository.getStopById = jest.fn(async () => {
|
||||||
|
return sampleStop;
|
||||||
|
});
|
||||||
|
|
||||||
await repository.updateEtasForSystemIfTTL("1");
|
await repository.updateEtasForSystemIfTTL("1");
|
||||||
|
|
||||||
const updatedResult = await repository.getEtasForStopId("177666");
|
const updatedResult = await repository.getEtasForStopId("177666");
|
||||||
|
|||||||
Reference in New Issue
Block a user