INSA: enable journeyLeg

This commit is contained in:
Jannis R 2018-03-13 21:04:42 +01:00
parent 68bf199673
commit ba97275bae
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 35 additions and 2 deletions

View file

@ -17,6 +17,11 @@ client.journeys('008010226', '008013456', {results: 1})
// longitude: 11.641705
// }, {distance: 200})
// .then(([journey]) => {
// const leg = journey.legs[0]
// return client.journeyLeg(leg.id, leg.line.name)
// })
.then(data => {
console.log(require('util').inspect(data, { depth: null }))
})

View file

@ -73,9 +73,9 @@ const insaProfile = {
parseProducts: createParseBitmask(products.allProducts, defaultProducts),
formatProducts,
parseLine: createParseLine
parseLine: createParseLine,
// todo: journeyLeg?
journeyLeg: true
// todo: radar?
}

View file

@ -255,6 +255,34 @@ test('nearby Magdeburg Hbf', co(function*(t) {
t.end()
}))
test('journey leg details', co(function* (t) {
const magdeburgHbf = '8010224'
const magdeburgBuckau = '8013456'
const [journey] = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
results: 1, when
})
const p = journey.legs[0]
t.ok(p, 'missing legs[0]')
t.ok(p.id, 'missing legs[0].id')
t.ok(p.line, 'missing legs[0].line')
t.ok(p.line.name, 'missing legs[0].line.name')
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
t.equal(typeof leg.id, 'string')
t.ok(leg.id)
assertValidLine(t, leg.line)
t.equal(typeof leg.direction, 'string')
t.ok(leg.direction)
t.ok(Array.isArray(leg.passed))
for (let passed of leg.passed) assertValidStopover(t, passed)
t.end()
}))
test('locations named Magdeburg', co(function*(t) {
const locations = yield client.locations('Magdeburg', {
results: 10