mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
fix tests 💚
This commit is contained in:
parent
ccfee97e4b
commit
5cb2b4f049
1 changed files with 13 additions and 5 deletions
|
@ -260,7 +260,9 @@ const validateJourneys = (val, js, name = 'journeys') => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const createValidateArrivalOrDeparture = (cfg) => {
|
const createValidateArrivalOrDeparture = (type, cfg) => {
|
||||||
|
if (type !== 'arrival' && type !== 'departure') throw new Error('invalid type')
|
||||||
|
|
||||||
const validateArrivalOrDeparture = (val, dep, name = 'arrOrDep') => {
|
const validateArrivalOrDeparture = (val, dep, name = 'arrOrDep') => {
|
||||||
a.ok(isObj(dep), name + ' must be an object')
|
a.ok(isObj(dep), name + ' must be an object')
|
||||||
// todo: let hafas-client add a .type field
|
// todo: let hafas-client add a .type field
|
||||||
|
@ -284,12 +286,18 @@ const createValidateArrivalOrDeparture = (cfg) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
val.line(val, dep.line, name + '.line')
|
val.line(val, dep.line, name + '.line')
|
||||||
a.strictEqual(typeof dep.direction, 'string', name + '.direction must be a string')
|
if (type === 'departure') {
|
||||||
a.ok(dep.direction, name + '.direction must not be empty')
|
const n = name + '.direction'
|
||||||
|
a.strictEqual(typeof dep.direction, 'string', n + ' must be a string')
|
||||||
|
a.ok(dep.direction, n + ' must not be empty')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return validateArrivalOrDeparture
|
return validateArrivalOrDeparture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createValidateArrival = cfg => createValidateArrivalOrDeparture('arrival', cfg)
|
||||||
|
const createValidateDeparture = cfg => createValidateArrivalOrDeparture('departure', cfg)
|
||||||
|
|
||||||
const validateArrivals = (val, deps, name = 'arrivals') => {
|
const validateArrivals = (val, deps, name = 'arrivals') => {
|
||||||
a.ok(Array.isArray(deps), name + ' must be an array')
|
a.ok(Array.isArray(deps), name + ' must be an array')
|
||||||
a.ok(deps.length > 0, name + ' must not be empty')
|
a.ok(deps.length > 0, name + ' must not be empty')
|
||||||
|
@ -362,8 +370,8 @@ module.exports = {
|
||||||
journeyLeg: createValidateJourneyLeg,
|
journeyLeg: createValidateJourneyLeg,
|
||||||
journey: () => validateJourney,
|
journey: () => validateJourney,
|
||||||
journeys: () => validateJourneys,
|
journeys: () => validateJourneys,
|
||||||
arrival: createValidateArrivalOrDeparture,
|
arrival: createValidateArrival,
|
||||||
departure: createValidateArrivalOrDeparture,
|
departure: createValidateDeparture,
|
||||||
departures: () => validateDepartures,
|
departures: () => validateDepartures,
|
||||||
arrivals: () => validateArrivals,
|
arrivals: () => validateArrivals,
|
||||||
movement: () => validateMovement,
|
movement: () => validateMovement,
|
||||||
|
|
Loading…
Add table
Reference in a new issue