db-vendo-client/test/e2e/lib/departures.js

24 lines
549 B
JavaScript
Raw Normal View History

2018-04-26 16:17:53 +02:00
'use strict'
2018-11-21 19:07:37 +01:00
const testDepartures = async (cfg) => {
2018-04-26 16:17:53 +02:00
const {test: t, departures: deps, validate, id} = cfg
validate(t, deps, 'departures', 'departures')
t.ok(deps.length > 0, 'must be >0 departures')
for (let i = 0; i < deps.length; i++) {
let stop = deps[i].stop
let name = `deps[${i}].stop`
if (stop.station) {
stop = stop.station
2018-07-11 13:25:22 +02:00
name += '.station'
}
2018-04-26 16:17:53 +02:00
t.equal(stop.id, id, name + '.id is invalid')
2018-04-26 16:17:53 +02:00
}
// todo: move into deps validator
2021-05-20 16:42:43 +01:00
t.same(deps, deps.sort((a, b) => t.when > b.when))
2018-11-21 19:07:37 +01:00
}
2018-04-26 16:17:53 +02:00
module.exports = testDepartures