mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
fix via 🐛, add tests ✅
This commit is contained in:
parent
cea043e44f
commit
20a2c8de94
4 changed files with 59 additions and 1 deletions
2
index.js
2
index.js
|
@ -83,7 +83,7 @@ const createClient = (profile) => {
|
||||||
maxChg: opt.transfers,
|
maxChg: opt.transfers,
|
||||||
minChgTime: opt.transferTime,
|
minChgTime: opt.transferTime,
|
||||||
depLocL: [from],
|
depLocL: [from],
|
||||||
viaLocL: opt.via ? [opt.via] : null,
|
viaLocL: opt.via ? [{loc: opt.via}] : null,
|
||||||
arrLocL: [to],
|
arrLocL: [to],
|
||||||
jnyFltrL: filters,
|
jnyFltrL: filters,
|
||||||
getTariff: !!opt.tickets,
|
getTariff: !!opt.tickets,
|
||||||
|
|
19
test/db.js
19
test/db.js
|
@ -209,6 +209,25 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co.wrap(function* (t) {
|
||||||
t.end()
|
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) {
|
test('departures at Berlin Jungfernheide', co.wrap(function* (t) {
|
||||||
const deps = yield client.departures('8011167', {
|
const deps = yield client.departures('8011167', {
|
||||||
duration: 5, when
|
duration: 5, when
|
||||||
|
|
19
test/oebb.js
19
test/oebb.js
|
@ -252,6 +252,25 @@ test('Albertina to Salzburg Hbf', co.wrap(function* (t) {
|
||||||
t.end()
|
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) {
|
test('leg details for Wien Westbahnhof to München Hbf', co.wrap(function* (t) {
|
||||||
const wienWestbahnhof = '1291501'
|
const wienWestbahnhof = '1291501'
|
||||||
const muenchenHbf = '8000261'
|
const muenchenHbf = '8000261'
|
||||||
|
|
20
test/vbb.js
20
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) {
|
test('departures', co.wrap(function* (t) {
|
||||||
const deps = yield client.departures(spichernstr, {duration: 5, when})
|
const deps = yield client.departures(spichernstr, {duration: 5, when})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue