mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
move mock data generators into test helpers folder
This commit is contained in:
53
test/testHelpers/mockDataGenerators.ts
Normal file
53
test/testHelpers/mockDataGenerators.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../../src/entities/entities";
|
||||
|
||||
// Use a single set of generators in case any of the
|
||||
// interfaces change in the future
|
||||
|
||||
export function generateMockSystems(): ISystem[] {
|
||||
return [
|
||||
{ id: "1", name: "System A" },
|
||||
{ id: "2", name: "System B" },
|
||||
{ id: "3", name: "System C" },
|
||||
];
|
||||
}
|
||||
|
||||
export function generateMockShuttles(): IShuttle[] {
|
||||
return [
|
||||
{ id: "sh1", name: "Shuttle A", routeId: "r1", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 } },
|
||||
{ id: "sh2", name: "Shuttle B", routeId: "r2", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 } },
|
||||
{ id: "sh3", name: "Shuttle C", routeId: "r3", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 } },
|
||||
];
|
||||
}
|
||||
|
||||
export function generateMockRoutes(): IRoute[] {
|
||||
return [
|
||||
{ id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [] },
|
||||
{ id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [] },
|
||||
{ id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [] },
|
||||
];
|
||||
}
|
||||
|
||||
export function generateMockStops(): IStop[] {
|
||||
return [
|
||||
{ id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 } },
|
||||
{ id: "st2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 } },
|
||||
{ id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 } },
|
||||
];
|
||||
}
|
||||
|
||||
export function generateMockOrderedStops(): IOrderedStop[] {
|
||||
return [
|
||||
{ stopId: "st1", routeId: "r1", position: 1 },
|
||||
{ stopId: "st1", routeId: "r2", position: 2 },
|
||||
{ stopId: "st2", routeId: "r1", position: 3 },
|
||||
{ stopId: "st2", routeId: "r2", position: 4 },
|
||||
];
|
||||
}
|
||||
|
||||
export function generateMockEtas(): IEta[] {
|
||||
return [
|
||||
{ shuttleId: "sh1", stopId: "st1", secondsRemaining: 120 },
|
||||
{ shuttleId: "sh1", stopId: "st2", secondsRemaining: 180 },
|
||||
{ shuttleId: "sh2", stopId: "st3", secondsRemaining: 240 },
|
||||
];
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
generateMockShuttles,
|
||||
generateMockStops,
|
||||
generateMockSystems
|
||||
} from "../generators";
|
||||
} from "./mockDataGenerators";
|
||||
|
||||
export async function addMockSystemToRepository(repository: UnoptimizedInMemoryRepository) {
|
||||
const mockSystems = generateMockSystems();
|
||||
|
||||
Reference in New Issue
Block a user