mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
disable getShuttlesByRouteId tests for now
This commit is contained in:
@@ -542,90 +542,91 @@ describe("getShuttleById", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getShuttlesBySystemId", () => {
|
||||
test("getShuttlesBySystemId returns old data if not expired", async () => {
|
||||
updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
|
||||
const initialCacheShuttle = {
|
||||
coordinates: {
|
||||
latitude: 33.791781,
|
||||
longitude: -117.8589646,
|
||||
},
|
||||
name: "08",
|
||||
routeId: "53966",
|
||||
systemId: "1",
|
||||
id: "5577",
|
||||
millisecondsSinceEpoch: Date.now() - 1000,
|
||||
};
|
||||
|
||||
const initialCache: ApiBasedRepositoryCache = {
|
||||
shuttlesBySystemId: {
|
||||
"1": [
|
||||
initialCacheShuttle,
|
||||
]
|
||||
},
|
||||
shuttleByShuttleId: {
|
||||
"5577": initialCacheShuttle,
|
||||
}
|
||||
};
|
||||
|
||||
const ttls: ApiBasedRepositoryMillisecondTTLs = {
|
||||
shuttleByShuttleId: 100000,
|
||||
shuttlesBySystemId: 100000,
|
||||
};
|
||||
|
||||
const repository = new ApiBasedRepository(initialCache, ttls);
|
||||
const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
expect(shuttles.length).toEqual(1);
|
||||
expect(shuttles[0].id).toEqual(initialCacheShuttle.id);
|
||||
});
|
||||
|
||||
test("getShuttlesBySystemId returns fresh data if expired", async () => {
|
||||
updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
|
||||
// TODO: move construction of shuttle into method
|
||||
const initialCacheShuttle = {
|
||||
coordinates: {
|
||||
latitude: 33.791781,
|
||||
longitude: -117.8589646,
|
||||
},
|
||||
name: "08",
|
||||
routeId: "53966",
|
||||
systemId: "1",
|
||||
id: "5577",
|
||||
millisecondsSinceEpoch: Date.now() - 100000,
|
||||
};
|
||||
|
||||
const initialCache: ApiBasedRepositoryCache = {
|
||||
shuttlesBySystemId: {
|
||||
"1": [
|
||||
initialCacheShuttle,
|
||||
]
|
||||
},
|
||||
shuttleByShuttleId: {
|
||||
"5577": initialCacheShuttle,
|
||||
}
|
||||
};
|
||||
|
||||
const ttls: ApiBasedRepositoryMillisecondTTLs = {
|
||||
shuttleByShuttleId: 1000,
|
||||
shuttlesBySystemId: 1000,
|
||||
};
|
||||
|
||||
const repository = new ApiBasedRepository(initialCache, ttls);
|
||||
const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
|
||||
expect(shuttles.length).toEqual(1);
|
||||
expect(shuttles[0].id).toEqual("5577");
|
||||
expect(shuttles[0].millisecondsSinceEpoch).not.toEqual(initialCacheShuttle.millisecondsSinceEpoch);
|
||||
});
|
||||
|
||||
test("getShuttlesBySystemId returns fresh data if no seeded data", async () => {
|
||||
updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
|
||||
const repository = new ApiBasedRepository();
|
||||
const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
|
||||
expect(shuttles.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
// TODO: enable when implemented
|
||||
// describe("getShuttlesBySystemId", () => {
|
||||
// test("getShuttlesBySystemId returns old data if not expired", async () => {
|
||||
// updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
//
|
||||
// const initialCacheShuttle = {
|
||||
// coordinates: {
|
||||
// latitude: 33.791781,
|
||||
// longitude: -117.8589646,
|
||||
// },
|
||||
// name: "08",
|
||||
// routeId: "53966",
|
||||
// systemId: "1",
|
||||
// id: "5577",
|
||||
// millisecondsSinceEpoch: Date.now() - 1000,
|
||||
// };
|
||||
//
|
||||
// const initialCache: ApiBasedRepositoryCache = {
|
||||
// shuttlesBySystemId: {
|
||||
// "1": [
|
||||
// initialCacheShuttle,
|
||||
// ]
|
||||
// },
|
||||
// shuttleByShuttleId: {
|
||||
// "5577": initialCacheShuttle,
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// const ttls: ApiBasedRepositoryMillisecondTTLs = {
|
||||
// shuttleByShuttleId: 100000,
|
||||
// shuttlesBySystemId: 100000,
|
||||
// };
|
||||
//
|
||||
// const repository = new ApiBasedRepository(initialCache, ttls);
|
||||
// const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
// expect(shuttles.length).toEqual(1);
|
||||
// expect(shuttles[0].id).toEqual(initialCacheShuttle.id);
|
||||
// });
|
||||
//
|
||||
// test("getShuttlesBySystemId returns fresh data if expired", async () => {
|
||||
// updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
//
|
||||
// // TODO: move construction of shuttle into method
|
||||
// const initialCacheShuttle = {
|
||||
// coordinates: {
|
||||
// latitude: 33.791781,
|
||||
// longitude: -117.8589646,
|
||||
// },
|
||||
// name: "08",
|
||||
// routeId: "53966",
|
||||
// systemId: "1",
|
||||
// id: "5577",
|
||||
// millisecondsSinceEpoch: Date.now() - 100000,
|
||||
// };
|
||||
//
|
||||
// const initialCache: ApiBasedRepositoryCache = {
|
||||
// shuttlesBySystemId: {
|
||||
// "1": [
|
||||
// initialCacheShuttle,
|
||||
// ]
|
||||
// },
|
||||
// shuttleByShuttleId: {
|
||||
// "5577": initialCacheShuttle,
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// const ttls: ApiBasedRepositoryMillisecondTTLs = {
|
||||
// shuttleByShuttleId: 1000,
|
||||
// shuttlesBySystemId: 1000,
|
||||
// };
|
||||
//
|
||||
// const repository = new ApiBasedRepository(initialCache, ttls);
|
||||
// const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
//
|
||||
// expect(shuttles.length).toEqual(1);
|
||||
// expect(shuttles[0].id).toEqual("5577");
|
||||
// expect(shuttles[0].millisecondsSinceEpoch).not.toEqual(initialCacheShuttle.millisecondsSinceEpoch);
|
||||
// });
|
||||
//
|
||||
// test("getShuttlesBySystemId returns fresh data if no seeded data", async () => {
|
||||
// updateGlobalFetchMockJson(genericShuttleDataBySystemId);
|
||||
//
|
||||
// const repository = new ApiBasedRepository();
|
||||
// const shuttles = await repository.getShuttlesBySystemId("1");
|
||||
//
|
||||
// expect(shuttles.length).toEqual(1);
|
||||
// });
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user