diff --git a/index.js b/index.js index 5c5f3a6a..a15259f4 100644 --- a/index.js +++ b/index.js @@ -83,7 +83,7 @@ const createClient = (profile) => { maxChg: opt.transfers, minChgTime: opt.transferTime, depLocL: [from], - viaLocL: opt.via ? [opt.via] : null, + viaLocL: opt.via ? [{loc: opt.via}] : null, arrLocL: [to], jnyFltrL: filters, getTariff: !!opt.tickets, diff --git a/test/db.js b/test/db.js index e1d07c00..4fe749db 100644 --- a/test/db.js +++ b/test/db.js @@ -209,6 +209,25 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co.wrap(function* (t) { t.end() })) +test('Berlin Hbf to München Hbf with stopover at Hannover Hbf', co.wrap(function* (t) { + const berlinHbf = '8011160' + const münchenHbf = '8000261' + const hannoverHbf = '8000152' + const [journey] = yield client.journeys(berlinHbf, münchenHbf, { + via: hannoverHbf, + results: 1 + }) + + const i = journey.legs.findIndex(leg => leg.destination.id === hannoverHbf) + t.ok(i >= 0, 'no leg with Hannover Hbf as destination') + + const nextLeg = journey.legs[i + 1] + t.ok(nextLeg) + t.equal(nextLeg.origin.id, hannoverHbf) + + t.end() +})) + test('departures at Berlin Jungfernheide', co.wrap(function* (t) { const deps = yield client.departures('8011167', { duration: 5, when diff --git a/test/oebb.js b/test/oebb.js index 261cb548..787eae15 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -252,6 +252,25 @@ test('Albertina to Salzburg Hbf', co.wrap(function* (t) { t.end() })) +test('Wien to Klagenfurt Hbf with stopover at Salzburg Hbf', co.wrap(function* (t) { + const wien = '1190100' + const klagenfurtHbf = '8100085' + const salzburgHbf = '8100002' + const [journey] = yield client.journeys(wien, klagenfurtHbf, { + via: salzburgHbf, + results: 1 + }) + + const i = journey.legs.findIndex(leg => leg.destination.id === salzburgHbf) + t.ok(i >= 0, 'no leg with Hannover Hbf as destination') + + const nextLeg = journey.legs[i + 1] + t.ok(nextLeg) + t.equal(nextLeg.origin.id, salzburgHbf) + + t.end() +})) + test('leg details for Wien Westbahnhof to München Hbf', co.wrap(function* (t) { const wienWestbahnhof = '1291501' const muenchenHbf = '8000261' diff --git a/test/vbb.js b/test/vbb.js index e613bdf7..d04edfb3 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -241,6 +241,26 @@ test('journeys – station to POI', co.wrap(function* (t) { +test('journeys – with stopover', co.wrap(function* (t) { + const halleschesTor = '900000012103' + const leopoldplatz = '900000009102' + const [journey] = yield client.journeys(spichernstr, halleschesTor, { + via: leopoldplatz, + results: 1 + }) + + const i = journey.legs.findIndex(leg => leg.destination.id === leopoldplatz) + t.ok(i >= 0, 'no leg with Leopoldplatz as destination') + + const nextLeg = journey.legs[i + 1] + t.ok(nextLeg) + t.equal(nextLeg.origin.id, leopoldplatz) + + t.end() +})) + + + test('departures', co.wrap(function* (t) { const deps = yield client.departures(spichernstr, {duration: 5, when})