Working on staffStation.utils and added tests
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
21
test/utils/translators/ldb/staffStation.utils.test.ts
Normal file
21
test/utils/translators/ldb/staffStation.utils.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { transform } from "../../../../src/utils/translators/ldb/staffStation";
|
||||
|
||||
import { inputs } from "./stationInputs.test.data";
|
||||
import { outputs } from "./stationOutputs.test.data";
|
||||
|
||||
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 + 1}`, () => {
|
||||
const input = inputs[testNo]
|
||||
const expectedOutput = outputs[testNo]
|
||||
|
||||
expect(transform(input)).toEqual(expectedOutput);
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
55
test/utils/translators/ldb/stationInputs.test.data.ts
Normal file
55
test/utils/translators/ldb/stationInputs.test.data.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
export const inputs: any[] = [
|
||||
{
|
||||
GetBoardResult: {
|
||||
generatedAt: '2023-08-01T20:37:05.559123+01:00',
|
||||
locationName: 'Railway Station',
|
||||
crs: 'RLY',
|
||||
stationManager: 'Network Rail',
|
||||
stationManagerCode: 'RT',
|
||||
nrccMessages: {
|
||||
message: {
|
||||
severity: "minor",
|
||||
xhtmlMessage: '\n<p>Minor Alert</p>',
|
||||
type: "station"
|
||||
}
|
||||
},
|
||||
isTruncated: 'true',
|
||||
trainServices: {
|
||||
service: [
|
||||
{
|
||||
rid: "202308017159276",
|
||||
uid: "G59276",
|
||||
trainuid: "1M83",
|
||||
sdd: "2023-08-01",
|
||||
operator: "CrossCountry",
|
||||
operatorCode: "XC",
|
||||
sta: "2023-08-01T20:24:00",
|
||||
ata: "2023-08-01T20:27:22",
|
||||
arrivalType: "Actual",
|
||||
std: "2023-08-01T20:35:00",
|
||||
etd: "2023-08-01T20:35:00",
|
||||
departureType: "Estimated",
|
||||
departureSource: "Darwin",
|
||||
platform: "5",
|
||||
origin: {
|
||||
location: {
|
||||
locationName: "Plymouth",
|
||||
crs: "PLY",
|
||||
tiploc: "PLYMTH"
|
||||
}
|
||||
},
|
||||
destination: {
|
||||
location: {
|
||||
locationName: "Birmingham New Street",
|
||||
crs: "BHM",
|
||||
tiploc: "BHAMNWS"
|
||||
}
|
||||
},
|
||||
category: "XX",
|
||||
activities: "T",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
40
test/utils/translators/ldb/stationOutputs.test.data.ts
Normal file
40
test/utils/translators/ldb/stationOutputs.test.data.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export const outputs: any[] = [
|
||||
{
|
||||
generatedAt: expect.any(Date),
|
||||
locationName: "Railway Station",
|
||||
stationManagerCode: "RT",
|
||||
nrccMessages: [
|
||||
{
|
||||
severity: "minor",
|
||||
xhtmlMessage: "Minor Alert"
|
||||
}
|
||||
],
|
||||
trainServices: [
|
||||
{
|
||||
rid: "202308017159276",
|
||||
uid: "G59276",
|
||||
trainuid: "1M83",
|
||||
operatorCode: "XC",
|
||||
sta: expect.any(Date),
|
||||
ata: expect.any(Date),
|
||||
arrivalType: "Actual",
|
||||
std: expect.any(Date),
|
||||
etd: expect.any(Date),
|
||||
departureType: "Estimated",
|
||||
platform: "5",
|
||||
origin: [
|
||||
{
|
||||
tiploc: "PLYMTH",
|
||||
locationName: "Plymouth"
|
||||
}
|
||||
],
|
||||
destination: [
|
||||
{
|
||||
tiploc: "BHAMNWS",
|
||||
locationName: "Birmingham New Street"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user