mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parent
a2cd5ba187
commit
c0a04fc74f
3 changed files with 67 additions and 0 deletions
13
test/db.js
13
test/db.js
|
@ -23,6 +23,7 @@ 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 testDeparturesWithoutRelatedStations = require('./lib/departures-without-related-stations')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
|
||||
|
@ -256,6 +257,18 @@ test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function*
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures without related stations', co(function* (t) {
|
||||
yield testDeparturesWithoutRelatedStations({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
id: '8089051', // Berlin Yorckstr. (S1)
|
||||
when,
|
||||
products: {bus: false},
|
||||
linesOfRelatedStations: ['S 2', 'S 25', 'S 26', 'U 7']
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
|
||||
const arrivals = yield client.arrivals(blnSchwedterStr, {
|
||||
duration: 5, when
|
||||
|
|
41
test/lib/departures-without-related-stations.js
Normal file
41
test/lib/departures-without-related-stations.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict'
|
||||
|
||||
const co = require('./co')
|
||||
|
||||
const testDeparturesWithoutUnrelatedStations = co(function* (cfg) {
|
||||
const {
|
||||
test: t,
|
||||
fetchDepartures,
|
||||
id,
|
||||
when
|
||||
// duration, products
|
||||
} = cfg
|
||||
|
||||
const relatedLines = cfg.linesOfRelatedStations
|
||||
.map(lName => lName.toLowerCase().trim())
|
||||
|
||||
const isUnrelatedLine = (dep) => {
|
||||
if (!dep.line || !dep.line.name) return false
|
||||
return relatedLines.includes(dep.line.name.toLowerCase().trim())
|
||||
}
|
||||
|
||||
const depsWith = yield fetchDepartures(id, {
|
||||
when,
|
||||
duration: cfg.duration || 20,
|
||||
products: cfg.products || {}
|
||||
})
|
||||
t.ok(depsWith.some(isUnrelatedLine), 'precondition failed: no line at related station found')
|
||||
|
||||
const depsWithout = yield fetchDepartures(id, {
|
||||
includeRelatedStations: false,
|
||||
when,
|
||||
duration: cfg.duration || 20,
|
||||
products: cfg.products || {}
|
||||
})
|
||||
|
||||
const unrelatedDep = depsWithout.find(isUnrelatedLine)
|
||||
if (unrelatedDep) t.fail('line at related station: ' + unrelatedDep.line.name)
|
||||
else t.pass('no lines from related stations')
|
||||
})
|
||||
|
||||
module.exports = testDeparturesWithoutUnrelatedStations
|
13
test/vbb.js
13
test/vbb.js
|
@ -27,6 +27,7 @@ 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 testDeparturesWithoutRelatedStations = require('./lib/departures-without-related-stations')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
const testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||
|
||||
|
@ -318,6 +319,18 @@ test('departures at 7-digit station', co(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
test('departures without related stations', co(function* (t) {
|
||||
yield testDeparturesWithoutRelatedStations({
|
||||
test: t,
|
||||
fetchDepartures: client.departures,
|
||||
id: '900000024101', // Charlottenburg
|
||||
when,
|
||||
products: {bus: false, suburban: false, regional: false},
|
||||
linesOfRelatedStations: ['U7']
|
||||
})
|
||||
t.end()
|
||||
}))
|
||||
|
||||
test('arrivals', co(function* (t) {
|
||||
const arrivals = yield client.arrivals(spichernstr, {
|
||||
duration: 5, when
|
||||
|
|
Loading…
Add table
Reference in a new issue