mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
DB, VBB: proper via tests ✅
This commit is contained in:
parent
95833edd21
commit
2506e4c495
2 changed files with 124 additions and 20 deletions
71
test/db.js
71
test/db.js
|
@ -217,18 +217,71 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('Berlin Hbf to München Hbf with stopover at Hannover Hbf', co(function* (t) {
|
test('journeys: via works – changing trains', co(function* (t) {
|
||||||
const [journey] = yield client.journeys(berlinHbf, münchenHbf, {
|
// Going from Westhafen to Wedding via Württembergalle without changing
|
||||||
via: hannoverHbf,
|
// is currently impossible. We check if the routing engine lets us change
|
||||||
results: 1
|
// at Württembergallee if we set it as via.
|
||||||
|
const westhafen = '008089116'
|
||||||
|
const wedding = '008089131'
|
||||||
|
const württembergallee = '731084'
|
||||||
|
const [journey] = yield client.journeys(westhafen, wedding, {
|
||||||
|
via: württembergallee,
|
||||||
|
results: 1,
|
||||||
|
when
|
||||||
})
|
})
|
||||||
|
|
||||||
const i = journey.legs.findIndex(leg => leg.destination.id === hannoverHbf)
|
t.ok(journey)
|
||||||
t.ok(i >= 0, 'no leg with Hannover Hbf as destination')
|
const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee)
|
||||||
|
t.ok(i1 >= 0, 'no leg with Württembergallee as destination')
|
||||||
|
|
||||||
const nextLeg = journey.legs[i + 1]
|
const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee)
|
||||||
t.ok(nextLeg)
|
t.ok(i2 >= 0, 'no leg with Württembergallee as origin')
|
||||||
t.equal(nextLeg.origin.id, hannoverHbf)
|
t.ok(i2 >= i1)
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
}))
|
||||||
|
|
||||||
|
test('journeys: via works – *without* changing trains', co(function* (t) {
|
||||||
|
// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
|
||||||
|
// to change trains. We check if the routing engine *does not* require
|
||||||
|
// one to change at the via station.
|
||||||
|
const ruhleben = '000731058'
|
||||||
|
const zoo = '008010406'
|
||||||
|
const kastanienallee = '730983'
|
||||||
|
const [journey] = yield client.journeys(ruhleben, zoo, {
|
||||||
|
via: kastanienallee,
|
||||||
|
results: 1,
|
||||||
|
when,
|
||||||
|
passedStations: true
|
||||||
|
})
|
||||||
|
|
||||||
|
t.ok(journey)
|
||||||
|
const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee)
|
||||||
|
t.ok(i1 < 0, 'routing engine changes at Kastanienallee')
|
||||||
|
|
||||||
|
const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee))
|
||||||
|
t.ok(l, 'no stopover at Kastanienallee')
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
}))
|
||||||
|
|
||||||
|
test('journeys: via works – even if on the obvious path', co(function* (t) {
|
||||||
|
const birkenwerder = '008080190'
|
||||||
|
const borgsdorf = '8080200'
|
||||||
|
const lehnitz = '008081722'
|
||||||
|
const [journey] = yield client.journeys(birkenwerder, lehnitz, {
|
||||||
|
via: borgsdorf,
|
||||||
|
results: 1,
|
||||||
|
when,
|
||||||
|
passedStations: true
|
||||||
|
})
|
||||||
|
|
||||||
|
t.ok(journey)
|
||||||
|
const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf)
|
||||||
|
t.ok(i1 < 0, 'routing engine changes at Borgsdorf')
|
||||||
|
|
||||||
|
const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf))
|
||||||
|
t.ok(l, 'no stopover at Borgsdorf')
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
73
test/vbb.js
73
test/vbb.js
|
@ -302,20 +302,71 @@ test('journeys – station to POI', co(function* (t) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test('journeys – with stopover', co(function* (t) {
|
test('journeys: via works – changing trains', co(function* (t) {
|
||||||
const halleschesTor = '900000012103'
|
// Going from Westhafen to Wedding via Württembergalle without changing
|
||||||
const leopoldplatz = '900000009102'
|
// is currently impossible. We check if the routing engine lets us change
|
||||||
const [journey] = yield client.journeys(spichernstr, halleschesTor, {
|
// at Württembergallee if we set it as via.
|
||||||
via: leopoldplatz,
|
const westhafen = '900000001201'
|
||||||
results: 1
|
const wedding = '900000009104'
|
||||||
|
const württembergallee = '900000026153'
|
||||||
|
const [journey] = yield client.journeys(westhafen, wedding, {
|
||||||
|
via: württembergallee,
|
||||||
|
results: 1,
|
||||||
|
when
|
||||||
})
|
})
|
||||||
|
|
||||||
const i = journey.legs.findIndex(leg => leg.destination.id === leopoldplatz)
|
t.ok(journey)
|
||||||
t.ok(i >= 0, 'no leg with Leopoldplatz as destination')
|
const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee)
|
||||||
|
t.ok(i1 >= 0, 'no leg with Württembergallee as destination')
|
||||||
|
|
||||||
const nextLeg = journey.legs[i + 1]
|
const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee)
|
||||||
t.ok(nextLeg)
|
t.ok(i2 >= 0, 'no leg with Württembergallee as origin')
|
||||||
t.equal(nextLeg.origin.id, leopoldplatz)
|
t.ok(i2 >= i1)
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
}))
|
||||||
|
|
||||||
|
test('journeys: via works – *without* changing trains', co(function* (t) {
|
||||||
|
// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
|
||||||
|
// to change trains. We check if the routing engine *does not* require
|
||||||
|
// one to change at the via station.
|
||||||
|
const ruhleben = '900000025202'
|
||||||
|
const zoo = '900000023201'
|
||||||
|
const kastanienallee = '900000020152'
|
||||||
|
const [journey] = yield client.journeys(ruhleben, zoo, {
|
||||||
|
via: kastanienallee,
|
||||||
|
results: 1,
|
||||||
|
when,
|
||||||
|
passedStations: true
|
||||||
|
})
|
||||||
|
|
||||||
|
t.ok(journey)
|
||||||
|
const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee)
|
||||||
|
t.ok(i1 < 0, 'routing engine changes at Kastanienallee')
|
||||||
|
|
||||||
|
const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee))
|
||||||
|
t.ok(l, 'no stopover at Kastanienallee')
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
}))
|
||||||
|
|
||||||
|
test('journeys: via works – even if on the obvious path', co(function* (t) {
|
||||||
|
const birkenwerder = '900000200008'
|
||||||
|
const borgsdorf = '900000200007'
|
||||||
|
const lehnitz = '900000200006'
|
||||||
|
const [journey] = yield client.journeys(birkenwerder, lehnitz, {
|
||||||
|
via: borgsdorf,
|
||||||
|
results: 1,
|
||||||
|
when,
|
||||||
|
passedStations: true
|
||||||
|
})
|
||||||
|
|
||||||
|
t.ok(journey)
|
||||||
|
const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf)
|
||||||
|
t.ok(i1 < 0, 'routing engine changes at Borgsdorf')
|
||||||
|
|
||||||
|
const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf))
|
||||||
|
t.ok(l, 'no stopover at Borgsdorf')
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue