mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add test case for fetch existing systems method
This commit is contained in:
@@ -4,6 +4,7 @@ import { UnoptimizedInMemoryRepository } from "../../src/repositories/Unoptimize
|
||||
import { fetchSystemDataSuccessfulResponse } from "../jsonSnapshots/fetchSystemData/fetchSystemDataSuccessfulResponse";
|
||||
import { fetchSystemDataFailedResponse } from "../jsonSnapshots/fetchSystemData/fetchSystemDataFailedResponse";
|
||||
import { fetchRouteDataSuccessfulResponse } from "../jsonSnapshots/fetchRouteData/fetchRouteDataSuccessfulResponse";
|
||||
import { ISystem } from "../../src/entities/entities";
|
||||
|
||||
/**
|
||||
* Function to update behavior of the global `fetch` function.
|
||||
@@ -79,9 +80,28 @@ describe("ApiBasedRepositoryLoader", () => {
|
||||
|
||||
|
||||
describe("fetchAndUpdateRouteDataForExistingSystemsInRepository", () => {
|
||||
// TODO
|
||||
// Add a test case to ensure that fetchAndUpdateRouteDataForSystemId
|
||||
// was called for every available system ID
|
||||
test("calls fetchAndUpdateRouteDataForSystemId for all systems in repository", async () => {
|
||||
const spy = jest.spyOn(loader, "fetchAndUpdateRouteDataForSystemId");
|
||||
|
||||
const systems: ISystem[] = [
|
||||
{
|
||||
name: "Chapman University",
|
||||
id: "1",
|
||||
},
|
||||
{
|
||||
name: "City of Monterey Park",
|
||||
id: "2",
|
||||
}
|
||||
];
|
||||
|
||||
await Promise.all(systems.map(async (system) => {
|
||||
await loader.repository.addOrUpdateSystem(system);
|
||||
}));
|
||||
|
||||
await loader.fetchAndUpdateRouteDataForExistingSystemsInRepository();
|
||||
|
||||
expect(spy.mock.calls.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fetchAndUpdateRouteDataForSystemId", () => {
|
||||
|
||||
Reference in New Issue
Block a user