mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tests for departure.nextStopovers/arrival.previousStopovers ✅
This commit is contained in:
parent
aa0f0118db
commit
f097022b9a
10 changed files with 52 additions and 15 deletions
|
@ -249,7 +249,8 @@ test('journeys: via works – with detour', co(function* (t) {
|
||||||
|
|
||||||
test('departures', co(function* (t) {
|
test('departures', co(function* (t) {
|
||||||
const departures = yield client.departures(spichernstr, {
|
const departures = yield client.departures(spichernstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
|
|
@ -178,7 +178,8 @@ test('trip details', co(function* (t) {
|
||||||
|
|
||||||
test('departures at Broadie Oaks', co(function*(t) {
|
test('departures at Broadie Oaks', co(function*(t) {
|
||||||
const departures = yield client.departures(broadieOaks, {
|
const departures = yield client.departures(broadieOaks, {
|
||||||
duration: 10, when
|
duration: 10, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
|
|
@ -245,7 +245,8 @@ test('trip details', co(function* (t) {
|
||||||
|
|
||||||
test('departures at Berlin Schwedter Str.', co(function* (t) {
|
test('departures at Berlin Schwedter Str.', co(function* (t) {
|
||||||
const departures = yield client.departures(blnSchwedterStr, {
|
const departures = yield client.departures(blnSchwedterStr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
@ -300,7 +301,8 @@ test('departures without related stations', co(function* (t) {
|
||||||
|
|
||||||
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
|
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
|
||||||
const arrivals = yield client.arrivals(blnSchwedterStr, {
|
const arrivals = yield client.arrivals(blnSchwedterStr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testArrivals({
|
yield testArrivals({
|
||||||
|
|
|
@ -171,7 +171,8 @@ test('trip details', co(function* (t) {
|
||||||
|
|
||||||
test('departures at Magdeburg Leiterstr.', co(function*(t) {
|
test('departures at Magdeburg Leiterstr.', co(function*(t) {
|
||||||
const departures = yield client.departures(leiterstr, {
|
const departures = yield client.departures(leiterstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
|
|
@ -334,8 +334,32 @@ const createValidateArrivalOrDeparture = (type, cfg) => {
|
||||||
return validateArrivalOrDeparture
|
return validateArrivalOrDeparture
|
||||||
}
|
}
|
||||||
|
|
||||||
const createValidateArrival = cfg => createValidateArrivalOrDeparture('arrival', cfg)
|
const createValidateArrival = (cfg) => {
|
||||||
const createValidateDeparture = cfg => createValidateArrivalOrDeparture('departure', cfg)
|
const validate = createValidateArrivalOrDeparture('arrival', cfg)
|
||||||
|
return (val, arr, name = 'arrival') => {
|
||||||
|
validate(val, arr, name)
|
||||||
|
if ('previousStopovers' in arr) {
|
||||||
|
const n = name + '.previousStopovers'
|
||||||
|
a.ok(Array.isArray(arr.previousStopovers), n + ' must be an array')
|
||||||
|
for (let i = 0; i < arr.previousStopovers.length; i++) {
|
||||||
|
val.stopover(val, arr.previousStopovers[i], n + `[${i}]`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const createValidateDeparture = (cfg) => {
|
||||||
|
const validate = createValidateArrivalOrDeparture('departure', cfg)
|
||||||
|
return (val, dep, name = 'departure') => {
|
||||||
|
validate(val, dep, name)
|
||||||
|
if ('nextStopovers' in dep) {
|
||||||
|
const n = name + '.nextStopovers'
|
||||||
|
a.ok(Array.isArray(dep.nextStopovers), n + ' must be an array')
|
||||||
|
for (let i = 0; i < dep.nextStopovers.length; i++) {
|
||||||
|
val.stopover(val, dep.nextStopovers[i], n + `[${i}]`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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')
|
||||||
|
|
|
@ -221,7 +221,8 @@ test('trip details', co(function* (t) {
|
||||||
|
|
||||||
test('departures at Kiel Räucherei', co(function* (t) {
|
test('departures at Kiel Räucherei', co(function* (t) {
|
||||||
const departures = yield client.departures(kielRaeucherei, {
|
const departures = yield client.departures(kielRaeucherei, {
|
||||||
duration: 30, when
|
duration: 30, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
|
|
@ -251,7 +251,8 @@ test('departures at Wien Leibenfrostgasse', co(function* (t) {
|
||||||
]
|
]
|
||||||
|
|
||||||
const deps = yield client.departures(wienLeibenfrostgasse, {
|
const deps = yield client.departures(wienLeibenfrostgasse, {
|
||||||
duration: 15, when
|
duration: 15, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, deps, 'departures', 'departures')
|
validate(t, deps, 'departures', 'departures')
|
||||||
|
|
|
@ -174,7 +174,8 @@ test('trip details', co(function* (t) {
|
||||||
|
|
||||||
test('departures at Karl-Theodor-Straße', co(function*(t) {
|
test('departures at Karl-Theodor-Straße', co(function*(t) {
|
||||||
const departures = yield client.departures(karlTheodorStr, {
|
const departures = yield client.departures(karlTheodorStr, {
|
||||||
duration: 10, when
|
duration: 10, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
@ -204,7 +205,8 @@ test('departures with station object', co(function* (t) {
|
||||||
|
|
||||||
test('arrivals at Karl-Theodor-Straße', co(function*(t) {
|
test('arrivals at Karl-Theodor-Straße', co(function*(t) {
|
||||||
const arrivals = yield client.arrivals(karlTheodorStr, {
|
const arrivals = yield client.arrivals(karlTheodorStr, {
|
||||||
duration: 10, when
|
duration: 10, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testArrivals({
|
yield testArrivals({
|
||||||
|
|
|
@ -224,7 +224,8 @@ test('journeys: via works – with detour', co(function* (t) {
|
||||||
|
|
||||||
test('departures', co(function* (t) {
|
test('departures', co(function* (t) {
|
||||||
const departures = yield client.departures(spichernstr, {
|
const departures = yield client.departures(spichernstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
@ -286,7 +287,8 @@ test('departures without related stations', co(function* (t) {
|
||||||
|
|
||||||
test('arrivals', co(function* (t) {
|
test('arrivals', co(function* (t) {
|
||||||
const arrivals = yield client.arrivals(spichernstr, {
|
const arrivals = yield client.arrivals(spichernstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testArrivals({
|
yield testArrivals({
|
||||||
|
|
|
@ -177,7 +177,8 @@ test.skip('trip details', co(function* (t) {
|
||||||
|
|
||||||
test.skip('departures at Magdeburg Leiterstr.', co(function*(t) {
|
test.skip('departures at Magdeburg Leiterstr.', co(function*(t) {
|
||||||
const departures = yield client.departures(leiterstr, {
|
const departures = yield client.departures(leiterstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: false
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testDepartures({
|
yield testDepartures({
|
||||||
|
@ -207,7 +208,8 @@ test.skip('departures with station object', co(function* (t) {
|
||||||
|
|
||||||
test.skip('arrivals at Magdeburg Leiterstr.', co(function*(t) {
|
test.skip('arrivals at Magdeburg Leiterstr.', co(function*(t) {
|
||||||
const arrivals = yield client.arrivals(leiterstr, {
|
const arrivals = yield client.arrivals(leiterstr, {
|
||||||
duration: 5, when
|
duration: 5, when,
|
||||||
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
yield testArrivals({
|
yield testArrivals({
|
||||||
|
|
Loading…
Add table
Reference in a new issue