tests for departure.nextStopovers/arrival.previousStopovers

This commit is contained in:
Jannis R 2018-12-28 21:17:03 +01:00
parent aa0f0118db
commit f097022b9a
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
10 changed files with 52 additions and 15 deletions

View file

@ -249,7 +249,8 @@ test('journeys: via works with detour', co(function* (t) {
test('departures', co(function* (t) {
const departures = yield client.departures(spichernstr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testDepartures({

View file

@ -178,7 +178,8 @@ test('trip details', co(function* (t) {
test('departures at Broadie Oaks', co(function*(t) {
const departures = yield client.departures(broadieOaks, {
duration: 10, when
duration: 10, when,
stopovers: true
})
yield testDepartures({

View file

@ -245,7 +245,8 @@ test('trip details', co(function* (t) {
test('departures at Berlin Schwedter Str.', co(function* (t) {
const departures = yield client.departures(blnSchwedterStr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testDepartures({
@ -300,7 +301,8 @@ test('departures without related stations', co(function* (t) {
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
const arrivals = yield client.arrivals(blnSchwedterStr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testArrivals({

View file

@ -171,7 +171,8 @@ test('trip details', co(function* (t) {
test('departures at Magdeburg Leiterstr.', co(function*(t) {
const departures = yield client.departures(leiterstr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testDepartures({

View file

@ -334,8 +334,32 @@ const createValidateArrivalOrDeparture = (type, cfg) => {
return validateArrivalOrDeparture
}
const createValidateArrival = cfg => createValidateArrivalOrDeparture('arrival', cfg)
const createValidateDeparture = cfg => createValidateArrivalOrDeparture('departure', cfg)
const createValidateArrival = (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') => {
a.ok(Array.isArray(deps), name + ' must be an array')

View file

@ -221,7 +221,8 @@ test('trip details', co(function* (t) {
test('departures at Kiel Räucherei', co(function* (t) {
const departures = yield client.departures(kielRaeucherei, {
duration: 30, when
duration: 30, when,
stopovers: true
})
yield testDepartures({

View file

@ -251,7 +251,8 @@ test('departures at Wien Leibenfrostgasse', co(function* (t) {
]
const deps = yield client.departures(wienLeibenfrostgasse, {
duration: 15, when
duration: 15, when,
stopovers: true
})
validate(t, deps, 'departures', 'departures')

View file

@ -174,7 +174,8 @@ test('trip details', co(function* (t) {
test('departures at Karl-Theodor-Straße', co(function*(t) {
const departures = yield client.departures(karlTheodorStr, {
duration: 10, when
duration: 10, when,
stopovers: true
})
yield testDepartures({
@ -204,7 +205,8 @@ test('departures with station object', co(function* (t) {
test('arrivals at Karl-Theodor-Straße', co(function*(t) {
const arrivals = yield client.arrivals(karlTheodorStr, {
duration: 10, when
duration: 10, when,
stopovers: true
})
yield testArrivals({

View file

@ -224,7 +224,8 @@ test('journeys: via works with detour', co(function* (t) {
test('departures', co(function* (t) {
const departures = yield client.departures(spichernstr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testDepartures({
@ -286,7 +287,8 @@ test('departures without related stations', co(function* (t) {
test('arrivals', co(function* (t) {
const arrivals = yield client.arrivals(spichernstr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testArrivals({

View file

@ -177,7 +177,8 @@ test.skip('trip details', co(function* (t) {
test.skip('departures at Magdeburg Leiterstr.', co(function*(t) {
const departures = yield client.departures(leiterstr, {
duration: 5, when
duration: 5, when,
stopovers: false
})
yield testDepartures({
@ -207,7 +208,8 @@ test.skip('departures with station object', co(function* (t) {
test.skip('arrivals at Magdeburg Leiterstr.', co(function*(t) {
const arrivals = yield client.arrivals(leiterstr, {
duration: 5, when
duration: 5, when,
stopovers: true
})
yield testArrivals({