diff --git a/src/utils/translators/ldb/staffStation.ts b/src/utils/translators/ldb/staffStation.ts index 3e3b5df..c30513b 100644 --- a/src/utils/translators/ldb/staffStation.ts +++ b/src/utils/translators/ldb/staffStation.ts @@ -105,7 +105,15 @@ function transformLocation(input: any): ServiceLocation[] { } function calculateLength(input: TrainServices): number | undefined { - console.log(input); + let length: number; + if (input?.length) { + length = input.length + return length + } + if (input?.formation?.coaches?.coach) { + length = input.formation.coaches.coach.length + return length + } return undefined } diff --git a/test/utils/translators/ldb/staffStation.utils.test.ts b/test/utils/translators/ldb/staffStation.utils.test.ts index 9eb5eef..4f839f6 100644 --- a/test/utils/translators/ldb/staffStation.utils.test.ts +++ b/test/utils/translators/ldb/staffStation.utils.test.ts @@ -19,3 +19,5 @@ describe('transform', () => { }); } }); + +// Write test for calculateLength(input: TrainServices): number | undefined \ No newline at end of file