mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
journeys fails with no product tests: use helper fn
This commit is contained in:
parent
2ffcf02946
commit
fecd2aefc0
6 changed files with 84 additions and 24 deletions
14
test/db.js
14
test/db.js
|
@ -19,6 +19,7 @@ const testJourneysStationToStation = require('./lib/journeys-station-to-station'
|
|||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
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 isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
||||
|
@ -92,7 +93,18 @@ test('journeys – Berlin Schwedter Str. to München Hbf', co(function* (t) {
|
|||
}))
|
||||
|
||||
// todo: journeys, only one product
|
||||
// todo: journeys, fails with no product
|
||||
|
||||
test('journeys – fails with no product', (t) => {
|
||||
journeysFailsWithNoProduct({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
fromId: blnSchwedterStr,
|
||||
toId: münchenHbf,
|
||||
when,
|
||||
products
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Berlin Schwedter Str. to Torfstraße 17', co(function* (t) {
|
||||
const torfstr = {
|
||||
|
|
14
test/insa.js
14
test/insa.js
|
@ -14,6 +14,7 @@ const testJourneysStationToStation = require('./lib/journeys-station-to-station'
|
|||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
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 isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
||||
|
@ -54,7 +55,18 @@ test('journeys – Magdeburg Hbf to Magdeburg-Buckau', co(function* (t) {
|
|||
}))
|
||||
|
||||
// todo: journeys, only one product
|
||||
// todo: journeys, fails with no product
|
||||
|
||||
test('journeys – fails with no product', (t) => {
|
||||
journeysFailsWithNoProduct({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
fromId: magdeburgHbf,
|
||||
toId: magdeburgBuckau,
|
||||
when,
|
||||
products
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
|
||||
const sternStr = {
|
||||
|
|
23
test/lib/journeys-fails-with-no-product.js
Normal file
23
test/lib/journeys-fails-with-no-product.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict'
|
||||
|
||||
const journeysFailsWithNoProduct = (cfg) => {
|
||||
const {
|
||||
test: t,
|
||||
fetchJourneys,
|
||||
fromId,
|
||||
toId,
|
||||
when,
|
||||
products
|
||||
} = cfg
|
||||
|
||||
const productsObj = Object.create(null)
|
||||
for (let p of products) productsObj[p.id] = false
|
||||
|
||||
t.throws(() => {
|
||||
client.journeys(fromId, toId, {when, products})
|
||||
// silence rejections, we're only interested in exceptions
|
||||
.catch(() => {})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = journeysFailsWithNoProduct
|
|
@ -18,6 +18,7 @@ const testJourneysStationToStation = require('./lib/journeys-station-to-station'
|
|||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
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 when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
@ -87,7 +88,18 @@ test('journeys – Kiel Hbf to Flensburg', co(function* (t) {
|
|||
}))
|
||||
|
||||
// todo: journeys, only one product
|
||||
// todo: journeys, fails with no product
|
||||
|
||||
test('journeys – fails with no product', (t) => {
|
||||
journeysFailsWithNoProduct({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
fromId: kielHbf,
|
||||
toId: flensburg,
|
||||
when,
|
||||
products
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Kiel Hbf to Husum, Zingel 10', co(function* (t) {
|
||||
const zingel = {
|
||||
|
|
14
test/oebb.js
14
test/oebb.js
|
@ -18,6 +18,7 @@ const testJourneysStationToStation = require('./lib/journeys-station-to-station'
|
|||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
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 when = createWhen('Europe/Vienna', 'de-AT')
|
||||
|
@ -79,7 +80,18 @@ test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
|
|||
}))
|
||||
|
||||
// todo: journeys, only one product
|
||||
// todo: journeys, fails with no product
|
||||
|
||||
test('journeys – fails with no product', (t) => {
|
||||
journeysFailsWithNoProduct({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
fromId: salzburgHbf,
|
||||
toId: wienFickeystr,
|
||||
when,
|
||||
products
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
|
||||
const wagramerStr = {
|
||||
|
|
29
test/vbb.js
29
test/vbb.js
|
@ -24,6 +24,7 @@ const testJourneysStationToStation = require('./lib/journeys-station-to-station'
|
|||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
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 when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
@ -159,26 +160,14 @@ test('journeys – only subway', co(function* (t) {
|
|||
}))
|
||||
|
||||
test('journeys – fails with no product', (t) => {
|
||||
// todo: make this test work
|
||||
// t.plan(1)
|
||||
try {
|
||||
client.journeys(spichernstr, bismarckstr, {
|
||||
when,
|
||||
products: {
|
||||
suburban: false,
|
||||
subway: false,
|
||||
tram: false,
|
||||
bus: false,
|
||||
ferry: false,
|
||||
express: false,
|
||||
regional: false
|
||||
}
|
||||
})
|
||||
// silence rejections, we're only interested in exceptions
|
||||
.catch(() => {})
|
||||
} catch (err) {
|
||||
t.ok(err, 'error thrown')
|
||||
}
|
||||
journeysFailsWithNoProduct({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
fromId: spichernstr,
|
||||
toId: bismarckstr,
|
||||
when,
|
||||
products
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue