mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
adapt tests & Nah.sh profile to 12e61be
This commit is contained in:
parent
e6130d7c23
commit
c4511c949c
6 changed files with 16 additions and 15 deletions
|
@ -84,7 +84,7 @@ const createParseMovement = (profile, opt, data) => {
|
|||
const res = _parseMovement(m)
|
||||
// filter out empty nextStops entries
|
||||
res.nextStops = res.nextStops.filter((f) => {
|
||||
return f.station !== null || f.arrival !== null || f.departure !== null
|
||||
return f.stop !== null || f.arrival !== null || f.departure !== null
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ const testArrivals = co(function* (cfg) {
|
|||
validate(t, arrs, 'arrivals', 'arrivals')
|
||||
t.ok(arrs.length > 0, 'must be >0 arrivals')
|
||||
for (let i = 0; i < arrs.length; i++) {
|
||||
let station = arrs[i].station
|
||||
let name = `arrs[${i}].station`
|
||||
if (station.station) {
|
||||
station = station.station
|
||||
let stop = arrs[i].stop
|
||||
let name = `arrs[${i}].stop`
|
||||
if (stop.station) {
|
||||
stop = stop.station
|
||||
name += '.station'
|
||||
}
|
||||
|
||||
t.equal(station.id, id, name + '.id is invalid')
|
||||
t.equal(stop.id, id, name + '.id is invalid')
|
||||
}
|
||||
|
||||
// todo: move into arrivals validator
|
||||
|
|
|
@ -8,14 +8,14 @@ const testDepartures = co(function* (cfg) {
|
|||
validate(t, deps, 'departures', 'departures')
|
||||
t.ok(deps.length > 0, 'must be >0 departures')
|
||||
for (let i = 0; i < deps.length; i++) {
|
||||
let station = deps[i].station
|
||||
let name = `deps[${i}].station`
|
||||
if (station.station) {
|
||||
station = station.station
|
||||
let stop = deps[i].stop
|
||||
let name = `deps[${i}].stop`
|
||||
if (stop.station) {
|
||||
stop = stop.station
|
||||
name += '.station'
|
||||
}
|
||||
|
||||
t.equal(station.id, id, name + '.id is invalid')
|
||||
t.equal(stop.id, id, name + '.id is invalid')
|
||||
}
|
||||
|
||||
// todo: move into deps validator
|
||||
|
|
|
@ -14,7 +14,8 @@ const testJourneysStationToAddress = co(function* (cfg) {
|
|||
const j = journeys[i]
|
||||
|
||||
const firstLeg = j.legs[0]
|
||||
t.strictEqual(firstLeg.origin.id, fromId)
|
||||
const orig = firstLeg.origin.station || firstLeg.origin
|
||||
t.ok(orig.id, fromId)
|
||||
|
||||
const d = j.legs[j.legs.length - 1].destination
|
||||
const n = `journeys[0].legs[${i}].destination`
|
||||
|
|
|
@ -262,7 +262,7 @@ const createValidateArrivalOrDeparture = (cfg) => {
|
|||
a.ok(dep.tripId, name + '.tripId must not be empty')
|
||||
a.strictEqual(typeof dep.trip, 'number', name + '.trip must be a number')
|
||||
|
||||
anyOf(['stop', 'station'], val, dep.station, name + '.station')
|
||||
anyOf(['stop', 'station'], val, dep.stop, name + '.stop')
|
||||
|
||||
assertValidWhen(dep.when, cfg.when, name)
|
||||
if (dep.delay !== null) {
|
||||
|
|
|
@ -246,8 +246,8 @@ test('departures at Wien Leibenfrostgasse', co(function* (t) {
|
|||
|
||||
for (let i = 0; i < deps.length; i++) {
|
||||
const dep = deps[i]
|
||||
const msg = `deps[${i}].station.id is invalid`
|
||||
t.ok(ids.includes(dep.station.id, msg))
|
||||
const msg = `deps[${i}].stop.id is invalid`
|
||||
t.ok(ids.includes(dep.stop.id, msg))
|
||||
}
|
||||
|
||||
t.end()
|
||||
|
|
Loading…
Add table
Reference in a new issue