backend/test/utils/translators/ldb/staffStation.utils.test.ts
Fred Boniface 31f104f51b Run prettier
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-08-26 00:38:26 +01:00

44 lines
1.2 KiB
TypeScript

import {
transform,
calculateLength,
} from "../../../../src/utils/translators/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);
});
}
});