Add calculateLength() code

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-08-05 01:04:41 +01:00
parent 23ad8969f9
commit 68207d1e5e
2 changed files with 11 additions and 1 deletions

View File

@ -105,7 +105,15 @@ function transformLocation(input: any): ServiceLocation[] {
} }
function calculateLength(input: TrainServices): number | undefined { 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 return undefined
} }

View File

@ -19,3 +19,5 @@ describe('transform', () => {
}); });
} }
}); });
// Write test for calculateLength(input: TrainServices): number | undefined