2023-08-26 00:38:26 +01:00
|
|
|
import {
|
|
|
|
transform,
|
|
|
|
calculateLength,
|
2023-10-12 20:53:52 +01:00
|
|
|
} from "../../../../src/utils/processors/ldb/staffStation";
|
2023-08-01 21:34:30 +01:00
|
|
|
|
2023-08-01 21:49:00 +01:00
|
|
|
import { inputs } from "./stationInputs";
|
|
|
|
import { outputs } from "./stationOutputs";
|
2023-08-05 22:59:56 +01:00
|
|
|
import { noLength as serviceNoLength } from "./trainServiceInputs";
|
|
|
|
import { trainServices } from "./trainServiceInputs";
|
2023-08-01 21:34:30 +01:00
|
|
|
|
2023-08-26 00:38:26 +01:00
|
|
|
describe("transform", () => {
|
|
|
|
test("Should return null for empty input", () => {
|
2023-08-01 21:34:30 +01:00
|
|
|
const input = {};
|
|
|
|
expect(transform(input)).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const testNo in inputs) {
|
2023-08-05 22:59:56 +01:00
|
|
|
test(`Should correctly transform data ${testNo}`, () => {
|
2023-08-26 00:38:26 +01:00
|
|
|
const input = inputs[testNo];
|
|
|
|
const expectedOutput = outputs[testNo];
|
2023-08-01 21:34:30 +01:00
|
|
|
|
|
|
|
expect(transform(input)).toEqual(expectedOutput);
|
|
|
|
});
|
|
|
|
}
|
2023-08-02 19:55:25 +01:00
|
|
|
});
|
2023-08-05 01:04:41 +01:00
|
|
|
|
2023-08-05 22:59:56 +01:00
|
|
|
// Write test for calculateLength(input: TrainServices): number | undefined
|
|
|
|
|
2023-08-26 00:38:26 +01:00
|
|
|
describe("calculateLength", () => {
|
|
|
|
test("Should return ubdefined for no length", () => {
|
2023-08-05 22:59:56 +01:00
|
|
|
const input = serviceNoLength;
|
|
|
|
expect(calculateLength(input)).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const testNo in trainServices) {
|
|
|
|
test(`Should correctly calculate ${testNo}`, () => {
|
2023-08-26 00:38:26 +01:00
|
|
|
const input = trainServices[testNo];
|
|
|
|
const expectedOutput = 4;
|
2023-08-05 22:59:56 +01:00
|
|
|
|
|
|
|
expect(calculateLength(input)).toEqual(expectedOutput);
|
|
|
|
});
|
|
|
|
}
|
2023-08-26 00:38:26 +01:00
|
|
|
});
|