Fred Boniface
c147d9c50c
Partial implementation of: #47 The 2022.2.1 release currently live is based off of the TimetableAPI-Upgrade branch. Partial PIS code matching is now implemented in cases where x number of stops need skipping at the start of a route. Reviewed-on: #64
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import {
|
|
transform,
|
|
calculateLength,
|
|
} from "../../../../src/utils/processors/ldb/staffStation";
|
|
|
|
import { inputs } from "./stationInputs";
|
|
import { outputs } from "./stationOutputs";
|
|
import { noLength as serviceNoLength } from "./trainServiceInputs";
|
|
import { trainServices } from "./trainServiceInputs";
|
|
|
|
describe("transform", () => {
|
|
test("Should return null for empty input", () => {
|
|
const input = {};
|
|
expect(transform(input)).toBeNull();
|
|
});
|
|
|
|
for (const testNo in inputs) {
|
|
test(`Should correctly transform data ${testNo}`, () => {
|
|
const input = inputs[testNo];
|
|
const expectedOutput = outputs[testNo];
|
|
|
|
expect(transform(input)).toEqual(expectedOutput);
|
|
});
|
|
}
|
|
});
|
|
|
|
// Write test for calculateLength(input: TrainServices): number | undefined
|
|
|
|
describe("calculateLength", () => {
|
|
test("Should return ubdefined for no length", () => {
|
|
const input = serviceNoLength;
|
|
expect(calculateLength(input)).toBeUndefined();
|
|
});
|
|
|
|
for (const testNo in trainServices) {
|
|
test(`Should correctly calculate ${testNo}`, () => {
|
|
const input = trainServices[testNo];
|
|
const expectedOutput = 4;
|
|
|
|
expect(calculateLength(input)).toEqual(expectedOutput);
|
|
});
|
|
}
|
|
});
|