2023-08-05 22:59:56 +01:00
|
|
|
import {
|
|
|
|
transform,
|
|
|
|
calculateLength
|
|
|
|
} from "../../../../src/utils/translators/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
|
|
|
|
|
|
|
describe('transform', () => {
|
|
|
|
test('Should return null for empty input', () => {
|
|
|
|
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-01 21:34:30 +01:00
|
|
|
const input = inputs[testNo]
|
|
|
|
const expectedOutput = outputs[testNo]
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|