Add test for calculateLength()

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface
2023-08-05 22:59:56 +01:00
parent ca6f245a84
commit de6f735edd
3 changed files with 69 additions and 6 deletions

View File

@@ -104,15 +104,15 @@ function transformLocation(input: any): ServiceLocation[] {
return output
}
function calculateLength(input: TrainServices): number | undefined {
export function calculateLength(input: any): number | undefined {
let length: number;
if (input?.length) {
length = input.length
return length
return Number(length)
}
if (input?.formation?.coaches?.coach) {
length = input.formation.coaches.coach.length
return length
return Number(length)
}
return undefined
}