mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +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 { fetchSystemDataSuccessfulResponse } from "../jsonSnapshots/fetchSystemData/fetchSystemDataSuccessfulResponse";
|
||||||
import { fetchSystemDataFailedResponse } from "../jsonSnapshots/fetchSystemData/fetchSystemDataFailedResponse";
|
import { fetchSystemDataFailedResponse } from "../jsonSnapshots/fetchSystemData/fetchSystemDataFailedResponse";
|
||||||
import { fetchRouteDataSuccessfulResponse } from "../jsonSnapshots/fetchRouteData/fetchRouteDataSuccessfulResponse";
|
import { fetchRouteDataSuccessfulResponse } from "../jsonSnapshots/fetchRouteData/fetchRouteDataSuccessfulResponse";
|
||||||
|
import { ISystem } from "../../src/entities/entities";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to update behavior of the global `fetch` function.
|
* Function to update behavior of the global `fetch` function.
|
||||||
@@ -79,9 +80,28 @@ describe("ApiBasedRepositoryLoader", () => {
|
|||||||
|
|
||||||
|
|
||||||
describe("fetchAndUpdateRouteDataForExistingSystemsInRepository", () => {
|
describe("fetchAndUpdateRouteDataForExistingSystemsInRepository", () => {
|
||||||
// TODO
|
test("calls fetchAndUpdateRouteDataForSystemId for all systems in repository", async () => {
|
||||||
// Add a test case to ensure that fetchAndUpdateRouteDataForSystemId
|
const spy = jest.spyOn(loader, "fetchAndUpdateRouteDataForSystemId");
|
||||||
// was called for every available system ID
|
|
||||||
|
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", () => {
|
describe("fetchAndUpdateRouteDataForSystemId", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user