mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tests for departures with direction option ✅
This commit is contained in:
parent
4a454917dd
commit
c80f355d47
6 changed files with 113 additions and 0 deletions
15
test/db.js
15
test/db.js
|
@ -22,6 +22,7 @@ const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
|||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testDepartures = require('./lib/departures')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
|
||||
|
@ -74,6 +75,7 @@ const westhafen = '008089116'
|
|||
const wedding = '008089131'
|
||||
const württembergallee = '731084'
|
||||
const regensburgHbf = '8000309'
|
||||
const blnOstbahnhof = '8010255'
|
||||
|
||||
test('journeys – Berlin Schwedter Str. to München Hbf', co(function* (t) {
|
||||
const journeys = yield client.journeys(blnSchwedterStr, münchenHbf, {
|
||||
|
@ -241,6 +243,19 @@ test('departures with station object', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function* (t) {
|
||||
yield testDeparturesInDirection({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
fetchTrip: client.trip,
|
||||
id: berlinHbf,
|
||||
directionIds: [blnOstbahnhof, '8089185', '732676'],
|
||||
when,
|
||||
validate
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
|
||||
const arrivals = yield client.arrivals(blnSchwedterStr, {
|
||||
duration: 5, when
|
||||
|
|
15
test/insa.js
15
test/insa.js
|
@ -16,6 +16,7 @@ const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
|||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testDepartures = require('./lib/departures')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
|
||||
|
@ -40,6 +41,7 @@ const leiterstr = '7464'
|
|||
const hasselbachplatzSternstrasse = '000006545'
|
||||
const stendal = '008010334'
|
||||
const dessau = '008010077'
|
||||
const universitaet = '19686'
|
||||
|
||||
test('journeys – Magdeburg Hbf to Magdeburg-Buckau', co(function* (t) {
|
||||
const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
|
||||
|
@ -196,6 +198,19 @@ test('departures with station object', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at Leiterstr in direction of Universität', co(function* (t) {
|
||||
yield testDeparturesInDirection({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
fetchTrip: client.trip,
|
||||
id: leiterstr,
|
||||
directionIds: [universitaet],
|
||||
when,
|
||||
validate
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('arrivals at Magdeburg Leiterstr.', co(function*(t) {
|
||||
const arrivals = yield client.arrivals(leiterstr, {
|
||||
duration: 5, when
|
||||
|
|
37
test/lib/departures-in-direction.js
Normal file
37
test/lib/departures-in-direction.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict'
|
||||
|
||||
const co = require('./co')
|
||||
|
||||
const testDeparturesInDirection = co(function* (cfg) {
|
||||
const {
|
||||
test: t,
|
||||
fetchDepartures,
|
||||
fetchTrip,
|
||||
id,
|
||||
directionIds,
|
||||
when,
|
||||
validate
|
||||
} = cfg
|
||||
|
||||
const deps = yield fetchDepartures(id, {
|
||||
direction: directionIds[0],
|
||||
when
|
||||
})
|
||||
validate(t, deps, 'departures', 'departures')
|
||||
t.ok(deps.length > 0, 'must be >0 departures')
|
||||
|
||||
for (let i = 0; i < deps.length; i++) {
|
||||
const dep = deps[i]
|
||||
const name = `deps[${i}]`
|
||||
|
||||
const line = dep.line && dep.line.name
|
||||
const trip = yield fetchTrip(dep.tripId, line, {
|
||||
when, stopovers: true
|
||||
})
|
||||
t.ok(trip.stopovers.some(st => {
|
||||
return st.stop && directionIds.includes(st.stop.id)
|
||||
}), `trip ${dep.tripId} of ${name} has no stopover at ${directionIds}`)
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = testDeparturesInDirection
|
|
@ -20,6 +20,7 @@ const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
|||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testDepartures = require('./lib/departures')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
|
||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
@ -65,6 +66,8 @@ const flensburg = '8000103'
|
|||
const luebeckHbf = '8000237'
|
||||
const husum = '8000181'
|
||||
const schleswig = '8005362'
|
||||
const ellerbekerMarkt = '9049027'
|
||||
const seefischmarkt = '9049245'
|
||||
|
||||
test('journeys – Kiel Hbf to Flensburg', co(function* (t) {
|
||||
const journeys = yield client.journeys(kielHbf, flensburg, {
|
||||
|
@ -230,6 +233,19 @@ test('departures with station object', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function* (t) {
|
||||
yield testDeparturesInDirection({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
fetchTrip: client.trip,
|
||||
id: ellerbekerMarkt,
|
||||
directionIds: [seefischmarkt, '710102'],
|
||||
when,
|
||||
validate
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('arrivals at Kiel Räucherei', co(function* (t) {
|
||||
const kielRaeucherei = '3440091'
|
||||
|
||||
|
|
16
test/oebb.js
16
test/oebb.js
|
@ -20,6 +20,7 @@ const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
|||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
|
||||
const when = createWhen('Europe/Vienna', 'de-AT')
|
||||
|
||||
|
@ -57,6 +58,8 @@ const wienWestbahnhof = '1291501'
|
|||
const klagenfurtHbf = '8100085'
|
||||
const muenchenHbf = '8000261'
|
||||
const wienRenngasse = '1390186'
|
||||
const wienKarlsplatz = '1390461'
|
||||
const wienPilgramgasse = '1390562'
|
||||
|
||||
test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
|
||||
const journeys = yield client.journeys(salzburgHbf, wienFickeystr, {
|
||||
|
@ -265,6 +268,19 @@ test('departures with station object', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at Karlsplatz in direction of Pilgramgasse', co(function* (t) {
|
||||
yield testDeparturesInDirection({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
fetchTrip: client.trip,
|
||||
id: wienKarlsplatz,
|
||||
directionIds: [wienPilgramgasse, '905002'],
|
||||
when,
|
||||
validate
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
// todo: arrivals
|
||||
|
||||
test('nearby Salzburg Hbf', co(function* (t) {
|
||||
|
|
14
test/vbb.js
14
test/vbb.js
|
@ -26,6 +26,7 @@ const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
|||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testDepartures = require('./lib/departures')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
|
||||
|
@ -297,6 +298,19 @@ test('departures with station object', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at Spichernstr. in direction of Westhafen', co(function* (t) {
|
||||
yield testDeparturesInDirection({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
fetchTrip: client.trip,
|
||||
id: spichernstr,
|
||||
directionIds: [westhafen],
|
||||
when,
|
||||
validate
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('departures at 7-digit station', co(function* (t) {
|
||||
const eisenach = '8010097' // see derhuerst/vbb-hafas#22
|
||||
yield client.departures(eisenach, {when})
|
||||
|
|
Loading…
Add table
Reference in a new issue