2018-05-13 00:34:26 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const co = require('./co')
|
|
|
|
|
|
|
|
const testJourneysWithDetour = co(function* (cfg) {
|
|
|
|
const {test: t, journeys, validate, detourIds} = cfg
|
|
|
|
|
|
|
|
// We assume that going from A to B via C *without* detour is currently
|
|
|
|
// impossible. We check if the routing engine computes a detour.
|
|
|
|
|
|
|
|
validate(t, journeys, 'journeys', 'journeys')
|
|
|
|
|
|
|
|
const leg = journeys[0].legs.some((leg) => {
|
2018-07-11 13:25:22 +02:00
|
|
|
return leg.stopovers && leg.stopovers.some((st) => (
|
|
|
|
st.stop.station && detourIds.includes(st.stop.station.id) ||
|
|
|
|
detourIds.includes(st.stop.id)
|
|
|
|
))
|
2018-05-13 00:34:26 +02:00
|
|
|
})
|
|
|
|
t.ok(leg, detourIds.join('/') + ' is not being passed')
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = testJourneysWithDetour
|