Merge pull request #26 from derhuerst/proper-via-tests

add proper via tests
This commit is contained in:
Julius Tens 2018-03-16 16:00:44 +01:00 committed by GitHub
commit afc95ed763
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 142 additions and 43 deletions

View file

@ -218,18 +218,44 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
t.end()
}))
test('Berlin Hbf to München Hbf with stopover at Hannover Hbf', co(function* (t) {
const [journey] = yield client.journeys(berlinHbf, münchenHbf, {
via: hannoverHbf,
results: 1
test('journeys: via works with detour', co(function* (t) {
// Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine computes a detour.
const westhafen = '008089116'
const wedding = '008089131'
const württembergallee = '731084'
const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee,
results: 1,
when,
passedStations: true
})
const i = journey.legs.findIndex(leg => leg.destination.id === hannoverHbf)
t.ok(i >= 0, 'no leg with Hannover Hbf as destination')
t.ok(journey)
const nextLeg = journey.legs[i + 1]
t.ok(nextLeg)
t.equal(nextLeg.origin.id, hannoverHbf)
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
t.ok(l, 'Württembergalle is not being passed')
t.end()
}))
test('journeys: via works without detour', co(function* (t) {
// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
// to change trains / no need for a "detour".
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 l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee))
t.ok(l, 'Kastanienallee is not being passed')
t.end()
}))

View file

@ -189,22 +189,47 @@ test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
t.end()
}))
test('Magdeburg-Buckau to Magdeburg-Neustadt with stopover at Magdeburg Hbf', co(function*(t) {
const magdeburgBuckau = '8013456'
const magdeburgNeustadt = '8010226'
const magdeburgHbf = '8010224'
const [journey] = yield client.journeys(magdeburgBuckau, magdeburgNeustadt, {
via: magdeburgHbf,
test('journeys: via works with detour', co(function* (t) {
// Going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Stendal via Dessau without detour
// is currently impossible. We check if the routing engine computes a detour.
const hasselbachplatzSternstrasse = '000006545'
const stendal = '008010334'
const dessau = '008010077'
const dessauPassed = '8010077'
const [journey] = yield client.journeys(hasselbachplatzSternstrasse, stendal, {
via: dessau,
results: 1,
when
when,
passedStations: true
})
const i1 = journey.legs.findIndex(leg => leg.destination.id === magdeburgHbf)
t.ok(i1 >= 0, 'no leg with Magdeburg Hbf as destination')
t.ok(journey)
const i2 = journey.legs.findIndex(leg => leg.origin.id === magdeburgHbf)
t.ok(i2 >= 0, 'no leg with Magdeburg Hbf as origin')
t.ok(i2 > i1, 'leg with Magdeburg Hbf as origin must be after leg to it')
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === dessauPassed))
t.ok(l, 'Dessau is not being passed')
t.end()
}))
test('journeys: via works without detour', co(function* (t) {
// When going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Magdeburg, Universität via Magdeburg, Breiter Weg, there is *no need*
// to change trains / no need for a "detour".
const hasselbachplatzSternstrasse = '000006545'
const universitaet = '000019686'
const breiterWeg = '000013519'
const breiterWegPassed = '13519'
const [journey] = yield client.journeys(hasselbachplatzSternstrasse, universitaet, {
via: breiterWeg,
results: 1,
when,
passedStations: true
})
t.ok(journey)
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === breiterWegPassed))
t.ok(l, 'Magdeburg, Breiter Weg is not being passed')
t.end()
}))

View file

@ -258,19 +258,47 @@ test('Albertina to Salzburg Hbf', co(function* (t) {
t.end()
}))
test('Wien to Klagenfurt Hbf with stopover at Salzburg Hbf', co(function* (t) {
const [journey] = yield client.journeys(wien, klagenfurtHbf, {
via: salzburgHbf,
test('journeys: via works with detour', co(function* (t) {
// Going from Stephansplatz to Schottenring via Donauinsel without detour
// is currently impossible. We check if the routing engine computes a detour.
const stephansplatz = '001390167'
const schottenring = '001390163'
const donauinsel = '001392277'
const donauinselPassed = '922001'
const [journey] = yield client.journeys(stephansplatz, schottenring, {
via: donauinsel,
results: 1,
when
when,
passedStations: true
})
const i1 = journey.legs.findIndex(leg => leg.destination.id === salzburgHbf)
t.ok(i1 >= 0, 'no leg with Salzburg Hbf as destination')
t.ok(journey)
const i2 = journey.legs.findIndex(leg => leg.origin.id === salzburgHbf)
t.ok(i2 >= 0, 'no leg with Salzburg Hbf as origin')
t.ok(i2 > i1, 'leg with Salzburg Hbf as origin must be after leg to it')
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === donauinselPassed))
t.ok(l, 'Donauinsel is not being passed')
t.end()
}))
test('journeys: via works without detour', co(function* (t) {
// When going from Karlsplatz to Praterstern via Museumsquartier, there is *no need*
// to change trains / no need for a "detour".
const karlsplatz = '001390461'
const praterstern = '001290201'
const museumsquartier = '001390171'
const museumsquartierPassed = '901014'
const [journey] = yield client.journeys(karlsplatz, praterstern, {
via: museumsquartier,
results: 1,
when,
passedStations: true
})
t.ok(journey)
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === museumsquartierPassed))
t.ok(l, 'Weihburggasse is not being passed')
t.end()
}))

View file

@ -300,27 +300,47 @@ test('journeys  station to POI', co(function* (t) {
t.end()
}))
test('journeys with stopover', co(function* (t) {
const halleschesTor = '900000012103'
const leopoldplatz = '900000009102'
const [journey] = yield client.journeys(spichernstr, halleschesTor, {
via: leopoldplatz,
results: 1
test('journeys: via works with detour', co(function* (t) {
// Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine computes a detour.
const westhafen = '900000001201'
const wedding = '900000009104'
const württembergallee = '900000026153'
const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee,
results: 1,
when,
passedStations: true
})
const i = journey.legs.findIndex(leg => leg.destination.id === leopoldplatz)
t.ok(i >= 0, 'no leg with Leopoldplatz as destination')
t.ok(journey)
const nextLeg = journey.legs[i + 1]
t.ok(nextLeg)
t.equal(nextLeg.origin.id, leopoldplatz)
const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
t.ok(l, 'Württembergalle is not being passed')
t.end()
}))
test('journeys: via works without detour', co(function* (t) {
// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
// to change trains / no need for a "detour".
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 l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee))
t.ok(l, 'Kastanienallee is not being passed')
t.end()
}))
test('departures', co(function* (t) {
const deps = yield client.departures(spichernstr, {duration: 5, when})