Rename getArrivedStopIfExists to getArrivedStopIfNextStop, and add more documentation
This commit is contained in:
@@ -4,10 +4,10 @@ import { UnoptimizedInMemoryShuttleRepository } from "../UnoptimizedInMemoryShut
|
||||
import { ShuttleGetterSetterRepository } from "../ShuttleGetterSetterRepository";
|
||||
import { RedisShuttleRepository } from "../RedisShuttleRepository";
|
||||
import {
|
||||
generateMockOrderedStops,
|
||||
generateMockRoutes,
|
||||
generateMockShuttles,
|
||||
generateMockStops,
|
||||
generateMockOrderedStops,
|
||||
generateMockRoutes,
|
||||
generateMockShuttles,
|
||||
generateMockStops,
|
||||
} from "../../../../testHelpers/mockDataGenerators";
|
||||
import { RepositoryHolder } from "../../../../testHelpers/RepositoryHolder";
|
||||
import { setupRouteAndOrderedStopsForShuttleRepository } from "../../../../testHelpers/setupRouteAndOrderedStopsForShuttleRepository";
|
||||
@@ -577,7 +577,7 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
test("gets any stop that the shuttle is currently at, if the shuttle has not had a last stop", async () => {
|
||||
const { sampleShuttleNotInRepository: shuttle } = await setupRouteAndOrderedStops();
|
||||
|
||||
const result = await repository.getArrivedStopIfExists(shuttle, false);
|
||||
const result = await repository.getArrivedStopIfNextStop(shuttle, false);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result?.id).toBe("st2");
|
||||
@@ -588,7 +588,7 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
const { sampleShuttleNotInRepository } = await setupRouteAndOrderedStops();
|
||||
const shuttle = { ...sampleShuttleNotInRepository, coordinates: { latitude: 12.5, longitude: 22.5 } }; // Not at any stop
|
||||
|
||||
const result = await repository.getArrivedStopIfExists(shuttle, false);
|
||||
const result = await repository.getArrivedStopIfNextStop(shuttle, false);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
@@ -599,11 +599,11 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
shuttle.coordinates = stop1.coordinates;
|
||||
await repository.addOrUpdateShuttle(shuttle);
|
||||
|
||||
let result = await repository.getArrivedStopIfExists(shuttle, false);
|
||||
let result = await repository.getArrivedStopIfNextStop(shuttle, false);
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
shuttle.coordinates = stop2.coordinates;
|
||||
result = await repository.getArrivedStopIfExists(shuttle, false);
|
||||
result = await repository.getArrivedStopIfNextStop(shuttle, false);
|
||||
expect(result).not.toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -613,7 +613,7 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
shuttle.coordinates = stop1.coordinates;
|
||||
await repository.addOrUpdateShuttle(shuttle);
|
||||
|
||||
const result = await repository.getArrivedStopIfExists(shuttle, true);
|
||||
const result = await repository.getArrivedStopIfNextStop(shuttle, true);
|
||||
expect(result?.id === stop1.id)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user