mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Update mocked methods in tests, and test method names to match
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, jest } from "@jest/globals";
|
import { afterEach, beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||||
import { TimedApiBasedRepositoryLoader } from "../TimedApiBasedRepositoryLoader";
|
import { TimedApiBasedRepositoryLoader } from "../TimedApiBasedRepositoryLoader";
|
||||||
import { resetGlobalFetchMockJson } from "../../../testHelpers/fetchMockHelpers";
|
import { resetGlobalFetchMockJson } from "../../../testHelpers/fetchMockHelpers";
|
||||||
import { UnoptimizedInMemoryShuttleRepository } from "../../repositories/shuttle/UnoptimizedInMemoryShuttleRepository";
|
import { UnoptimizedInMemoryShuttleRepository } from "../../repositories/shuttle/UnoptimizedInMemoryShuttleRepository";
|
||||||
@@ -23,7 +23,7 @@ describe("TimedApiBasedRepositoryLoader", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
spies = {
|
spies = {
|
||||||
fetchAndUpdateAll: jest.spyOn(mockLoader, 'fetchAndUpdateAll'),
|
updateAll: jest.spyOn(mockLoader, 'updateAll'),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.values(spies).forEach((spy: any) => {
|
Object.values(spies).forEach((spy: any) => {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
|
|
||||||
const systemId = "1";
|
const systemId = "1";
|
||||||
|
|
||||||
describe("fetchAndUpdateAll", () => {
|
describe("updateAll", () => {
|
||||||
it("calls all the correct methods", async () => {
|
it("calls all the correct methods", async () => {
|
||||||
const spies = {
|
const spies = {
|
||||||
updateRouteDataForSystem: jest.spyOn(loader, "updateRouteDataForSystem"),
|
updateRouteDataForSystem: jest.spyOn(loader, "updateRouteDataForSystem"),
|
||||||
@@ -52,7 +52,7 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fetchAndUpdateRouteDataForSystem", () => {
|
describe("updateRouteDataForSystem", () => {
|
||||||
it("updates route data in repository if response received", async () => {
|
it("updates route data in repository if response received", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
// Test pruning
|
// Test pruning
|
||||||
@@ -85,7 +85,7 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fetchAndUpdateStopAndPolylineDataForRoutesWithSystemId", () => {
|
describe("updateStopAndPolylineDataForRoutesInSystem", () => {
|
||||||
it("updates stop and polyline data if response received", async () => {
|
it("updates stop and polyline data if response received", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
// Test pruning of stops only
|
// Test pruning of stops only
|
||||||
@@ -124,7 +124,7 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fetchAndUpdateShuttleDataForSystem", () => {
|
describe("updateShuttleDataForSystem", () => {
|
||||||
it("updates shuttle data in repository if response received", async () => {
|
it("updates shuttle data in repository if response received", async () => {
|
||||||
const shuttlesToPrune = generateMockShuttles();
|
const shuttlesToPrune = generateMockShuttles();
|
||||||
await Promise.all(shuttlesToPrune.map(async (shuttle) => {
|
await Promise.all(shuttlesToPrune.map(async (shuttle) => {
|
||||||
@@ -151,8 +151,8 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fetchAndUpdateEtaDataForExistingStopsForSystem", () => {
|
describe("updateEtaDataForExistingStopsForSystem", () => {
|
||||||
it("calls fetchAndUpdateEtaDataForStopId for every stop in repository", async () => {
|
it("calls updateEtaDataForStopId for every stop in repository", async () => {
|
||||||
const spy = jest.spyOn(loader, "updateEtaDataForStopId");
|
const spy = jest.spyOn(loader, "updateEtaDataForStopId");
|
||||||
|
|
||||||
const stops = generateMockStops();
|
const stops = generateMockStops();
|
||||||
@@ -170,7 +170,7 @@ describe("ApiBasedShuttleRepositoryLoader", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fetchAndUpdateEtaDataForStopId", () => {
|
describe("updateEtaDataForStopId", () => {
|
||||||
const stopId = "177666";
|
const stopId = "177666";
|
||||||
it("updates ETA data for stop id if response received", async () => {
|
it("updates ETA data for stop id if response received", async () => {
|
||||||
updateGlobalFetchMockJson(fetchEtaDataSuccessfulResponse);
|
updateGlobalFetchMockJson(fetchEtaDataSuccessfulResponse);
|
||||||
|
|||||||
Reference in New Issue
Block a user