add test for updateEtasForSystemIfTTL for updating data

This commit is contained in:
2025-01-07 19:41:01 -08:00
parent e19e14cce7
commit 9db745bd12

View File

@@ -142,60 +142,6 @@ const genericEtaDataByStopId = {
"stopId": "177666"
}
},
{
"OOS": 0,
"busName": "10",
"distance": 1,
"speed": 11.085164763991688,
"routeBlockId": "142270",
"actualRouteBlockId": "142270",
"arrived": null,
"eta": "19 min ",
"color": "#000000",
"bg": "#ffea3f",
"order": 0,
"dwell": null,
"stopsAmount": 2,
"secondsSpent": 1150,
"etaR": "19",
"error": null,
"outdated": 0,
"routeId": "53966",
"serviceTime": "",
"scheduleTimes": [],
"goShowSchedule": 0,
"looping": "1",
"routeGroupId": "6703",
"busId": 7105,
"tripId": 751430,
"deviceId": 404873,
"created": "2025-01-07 15:00:08",
"routePointPosition": 254,
"routeStopPosition": 3,
"stopRoutePointPosition": 217,
"timezoneOffset": -10800,
"busLatLng": [
33.7917895,
-117.8901868
],
"busProjectionLatlng": {
"lat": 33.79179583075815,
"lng": -117.8902164019431
},
"busProjectionError": 3,
"stopId": "177666",
"theStop": {
"name": "Chapman Court",
"position": 3,
"userId": "263",
"routeStopId": "1348785",
"busId": 7105,
"routeName": "Red Route",
"shortName": null,
"routeId": "53966",
"stopId": "177666"
}
}
]
}
@@ -361,9 +307,27 @@ describe("updateEtasForSystemIfTTL", () => {
});
test("updateEtasForSystemIfTTL updates all ETA data if data is TTL", async () => {
// For this one, stub out getStopsBySystemId to return mock data
updateGlobalFetchMockJson(genericEtaDataByStopId);
const repository = new ApiBasedRepository();
repository.getStopsBySystemId = jest.fn(async () => {
return [
{
name: "Chapman Court",
systemId: "1",
id: "177666",
coordinates: {
latitude: 33.796796,
longitude: -117.889293
},
}
];
});
})
await repository.updateEtasForSystemIfTTL("1");
const updatedResult = await repository.getEtasForStopId("177666");
expect(updatedResult.length).toEqual(2);
});
});