Additional tests
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
2d2fdbb8db
commit
9ab6741243
@ -63,12 +63,12 @@ function transformTrainServices(input: any): TrainServices[] {
|
||||
uid: service?.uid,
|
||||
trainid: service?.trainid,
|
||||
operatorCode: service?.operatorCode || 'UK',
|
||||
platform: service?.platform || '',
|
||||
platformIsHidden: service?.platformIsHidden || '',
|
||||
serviceIsSupressed: service?.serviceIsSupressed || '',
|
||||
platform: service?.platform || '-',
|
||||
platformIsHidden: service?.platformIsHidden,
|
||||
serviceIsSupressed: service?.serviceIsSupressed,
|
||||
origin: transformLocation(service?.origin),
|
||||
destination: transformLocation(service?.destination),
|
||||
isCancelled: service?.isCancelled || '',
|
||||
isCancelled: service?.isCancelled,
|
||||
cancelReason: service?.cancelReason,
|
||||
delayReason: service?.delayReason,
|
||||
arrivalType: service?.arrivalType,
|
||||
@ -80,6 +80,7 @@ function transformTrainServices(input: any): TrainServices[] {
|
||||
etd: transformUnspecifiedDateTime(service?.etd),
|
||||
atd: transformUnspecifiedDateTime(service?.atd),
|
||||
}
|
||||
Object.keys(trainService).forEach(key => trainService[key] === undefined && delete trainService[key]);
|
||||
output.push(trainService)
|
||||
}
|
||||
return output
|
||||
@ -101,8 +102,11 @@ function transformLocation(input: any): ServiceLocation[] {
|
||||
return output
|
||||
}
|
||||
|
||||
function transformUnspecifiedDateTime(input: string): Date {
|
||||
function transformUnspecifiedDateTime(input: string): Date | undefined {
|
||||
console.debug(`staffStation.transformUnspecifiedDateTime running`)
|
||||
if (!input) {
|
||||
return undefined
|
||||
}
|
||||
const date = tz(input, "Europe/London");
|
||||
return date.toDate()
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { getDomainFromEmail } from "../../src/utils/sanitizer.utils";
|
||||
import { removeNonNumeric } from "../../src/utils/sanitizer.utils";
|
||||
|
||||
describe('Sanitize Email', () => {
|
||||
const inputs = [
|
||||
@ -16,3 +17,15 @@ describe('Sanitize Email', () => {
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
describe('Remove non-numeric', () => {
|
||||
const inputs = ['abc123','<%43)($£@:}jfkd4']
|
||||
const expectedOutputs = ['123','434']
|
||||
for (const key in inputs) {
|
||||
const input = inputs[key];
|
||||
const desired = expectedOutputs[key];
|
||||
test(`Should return only numbers: ${key}`, () => {
|
||||
expect(removeNonNumeric(input)).toEqual(desired);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ export const outputs: any[] = [
|
||||
{
|
||||
rid: "202308017159276",
|
||||
uid: "G59276",
|
||||
trainuid: "1M83",
|
||||
trainid: "1M83",
|
||||
operatorCode: "XC",
|
||||
sta: expect.any(Date),
|
||||
ata: expect.any(Date),
|
||||
|
Loading…
Reference in New Issue
Block a user