mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09: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') => {
|
||||
a.ok(isObj(dep), name + ' must be an object')
|
||||
// todo: let hafas-client add a .type field
|
||||
|
@ -284,12 +286,18 @@ const createValidateArrivalOrDeparture = (cfg) => {
|
|||
}
|
||||
|
||||
val.line(val, dep.line, name + '.line')
|
||||
a.strictEqual(typeof dep.direction, 'string', name + '.direction must be a string')
|
||||
a.ok(dep.direction, name + '.direction must not be empty')
|
||||
if (type === 'departure') {
|
||||
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
|
||||
}
|
||||
|
||||
const createValidateArrival = cfg => createValidateArrivalOrDeparture('arrival', cfg)
|
||||
const createValidateDeparture = cfg => createValidateArrivalOrDeparture('departure', cfg)
|
||||
|
||||
const validateArrivals = (val, deps, name = 'arrivals') => {
|
||||
a.ok(Array.isArray(deps), name + ' must be an array')
|
||||
a.ok(deps.length > 0, name + ' must not be empty')
|
||||
|
@ -362,8 +370,8 @@ module.exports = {
|
|||
journeyLeg: createValidateJourneyLeg,
|
||||
journey: () => validateJourney,
|
||||
journeys: () => validateJourneys,
|
||||
arrival: createValidateArrivalOrDeparture,
|
||||
departure: createValidateArrivalOrDeparture,
|
||||
arrival: createValidateArrival,
|
||||
departure: createValidateDeparture,
|
||||
departures: () => validateDepartures,
|
||||
arrivals: () => validateArrivals,
|
||||
movement: () => validateMovement,
|
||||
|
|
Loading…
Add table
Reference in a new issue