diff --git a/p/insa/example.js b/p/insa/example.js index 2531ec5b..1a46a1d6 100644 --- a/p/insa/example.js +++ b/p/insa/example.js @@ -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 })) }) diff --git a/p/insa/index.js b/p/insa/index.js index 229fbd54..ee1b8973 100644 --- a/p/insa/index.js +++ b/p/insa/index.js @@ -73,9 +73,9 @@ const insaProfile = { parseProducts: createParseBitmask(products.allProducts, defaultProducts), formatProducts, - parseLine: createParseLine + parseLine: createParseLine, - // todo: journeyLeg? + journeyLeg: true // todo: radar? } diff --git a/test/insa.js b/test/insa.js index 67f32352..09be1d80 100644 --- a/test/insa.js +++ b/test/insa.js @@ -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