Add calculateLength() code
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
23ad8969f9
commit
68207d1e5e
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,3 +19,5 @@ describe('transform', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Write test for calculateLength(input: TrainServices): number | undefined
|
Loading…
Reference in New Issue
Block a user