tape + tap-spec -> tap

This commit is contained in:
Jannis R 2021-05-20 16:42:43 +01:00
parent 40ec157869
commit f1a19450fe
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
69 changed files with 507 additions and 574 deletions

View file

@ -67,17 +67,19 @@
"is-coordinates": "^2.0.2", "is-coordinates": "^2.0.2",
"is-roughly-equal": "^0.1.0", "is-roughly-equal": "^0.1.0",
"replayer": "^2.2.3", "replayer": "^2.2.3",
"tap-spec": "^5.0.0", "tap": "^15.0.9",
"tape": "^5.0.0",
"validate-fptf": "^3.0.0" "validate-fptf": "^3.0.0"
}, },
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"test-unit": "node test/index.js | tap-spec", "test-unit": "tap test/*.js test/format/*.js test/parse/*.js",
"test-integration": "VCR_MODE=playback node test/e2e/index.js | tap-spec", "test-integration": "VCR_MODE=playback tap test/e2e/*.js",
"test-integration:record": "VCR_MODE=record node test/e2e/index.js | tap-spec", "test-integration:record": "VCR_MODE=record tap test/e2e/*.js",
"test-e2e": "VCR_OFF=true node test/e2e/index.js | tap-spec", "test-e2e": "VCR_OFF=true tap test/e2e/*.js",
"test": "npm run test-unit && npm run test-integration", "test": "npm run test-unit && npm run test-integration",
"prepublishOnly": "npm run lint && npm test" "prepublishOnly": "npm run lint && npm test"
},
"tap": {
"coverage": false
} }
} }

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/bvg') const rawProfile = require('../p/bvg')
@ -28,11 +28,11 @@ const opt = {
products: {} products: {}
} }
test('parses a journey correctly (BVG)', (t) => { tap.test('parses a journey correctly (BVG)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journey = profile.parseJourney(ctx, res.outConL[0]) const journey = profile.parseJourney(ctx, res.outConL[0])
t.deepEqual(journey, expected) t.same(journey, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/bvg') const rawProfile = require('../p/bvg')
@ -20,11 +20,11 @@ const opt = {
products: {} products: {}
} }
test('parses a radar() response correctly (BVG)', (t) => { tap.test('parses a radar() response correctly (BVG)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const movements = res.jnyL.map(m => profile.parseMovement(ctx, m)) const movements = res.jnyL.map(m => profile.parseMovement(ctx, m))
t.deepEqual(movements, expected) t.same(movements, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/db') const rawProfile = require('../p/db')
@ -21,11 +21,11 @@ const opt = {
products: {} products: {}
} }
test('parses an arrival correctly (DB)', (t) => { tap.test('parses an arrival correctly (DB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const arrivals = res.jnyL.map(d => profile.parseArrival(ctx, d)) const arrivals = res.jnyL.map(d => profile.parseArrival(ctx, d))
t.deepEqual(arrivals, expected) t.same(arrivals, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/db') const rawProfile = require('../p/db')
@ -28,11 +28,11 @@ const opt = {
products: {} products: {}
} }
test('parses a journey remarks without failing', (t) => { tap.test('parses a journey remarks without failing', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journey = profile.parseJourney(ctx, res.outConL[2]) const journey = profile.parseJourney(ctx, res.outConL[2])
t.deepEqual(journey, expected) t.same(journey, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/db') const rawProfile = require('../p/db')
@ -28,11 +28,11 @@ const opt = {
products: {}, products: {},
} }
test('parses a journey with an embedded polyline correctly', (t) => { tap.test('parses a journey with an embedded polyline correctly', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journey = profile.parseJourney(ctx, res.outConL[0]) const journey = profile.parseJourney(ctx, res.outConL[0])
t.deepEqual(journey, expected) t.same(journey, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/db') const rawProfile = require('../p/db')
@ -28,11 +28,11 @@ const opt = {
products: {} products: {}
} }
test('parses a journey with a DEVI leg correctly (DB)', (t) => { tap.test('parses a journey with a DEVI leg correctly (DB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journey = profile.parseJourney(ctx, res.outConL[2]) const journey = profile.parseJourney(ctx, res.outConL[2])
t.deepEqual(journey, expected) t.same(journey, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parseCommon = require('../parse/common') const parseCommon = require('../parse/common')
const defaultProfile = require('../lib/default-profile') const defaultProfile = require('../lib/default-profile')
@ -21,12 +21,12 @@ const opt = {
remarks: true remarks: true
} }
test('parseCommon parses a DB Netz response properly', (t) => { tap.test('parseCommon parses a DB Netz response properly', (t) => {
const {warnings} = profile.parseCommon({profile, opt, res}) const {warnings} = profile.parseCommon({profile, opt, res})
t.pass('parsed without throwing') t.pass('parsed without throwing')
const warning = warnings.find(w => w.id === 'HIM_FREETEXT_447862') const warning = warnings.find(w => w.id === 'HIM_FREETEXT_447862')
t.deepEqual(warning, { t.same(warning, {
id: 'HIM_FREETEXT_447862', id: 'HIM_FREETEXT_447862',
type: 'warning', type: 'warning',
summary: 'Abweichung Fpl f Zmst BKRW - NEB nur nach Gl101', summary: 'Abweichung Fpl f Zmst BKRW - NEB nur nach Gl101',

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/db') const rawProfile = require('../p/db')
@ -17,11 +17,11 @@ const opt = {
remarks: true, remarks: true,
} }
test('parses a stop() response correctly (DB)', (t) => { tap.test('parses a stop() response correctly (DB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const stop = profile.parseLocation(ctx, res.locL[0]) const stop = profile.parseLocation(ctx, res.locL[0])
t.deepEqual(stop, expected) t.same(stop, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,7 @@
'use strict' 'use strict'
// todo: DRY with vbb tests // todo: DRY with vbb tests
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {DateTime} = require('luxon') const {DateTime} = require('luxon')
@ -18,7 +19,6 @@ const {
validateDeparture, validateDeparture,
validateMovement validateMovement
} = require('./lib/vbb-bvg-validators') } = require('./lib/vbb-bvg-validators')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -56,7 +56,7 @@ const jannowitzbrücke = '900000100004'
const hour = 60 * 60 * 1000 const hour = 60 * 60 * 1000
test('journeys  Spichernstr. to Bismarckstr.', async (t) => { tap.test('journeys  Spichernstr. to Bismarckstr.', async (t) => {
const res = await client.journeys(spichernstr, bismarckstr, { const res = await client.journeys(spichernstr, bismarckstr, {
results: 4, results: 4,
departure: when, departure: when,
@ -75,7 +75,7 @@ test('journeys  Spichernstr. to Bismarckstr.', async (t) => {
t.end() t.end()
}) })
test('journeys  only subway', async (t) => { tap.test('journeys  only subway', async (t) => {
const res = await client.journeys(spichernstr, bismarckstr, { const res = await client.journeys(spichernstr, bismarckstr, {
results: 20, results: 20,
departure: when, departure: when,
@ -110,7 +110,7 @@ test('journeys  only subway', async (t) => {
t.end() t.end()
}) })
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -123,7 +123,7 @@ test('journeys  fails with no product', (t) => {
}) })
// BerlKönig for public use is suspended during COVID-19. // BerlKönig for public use is suspended during COVID-19.
test.skip('journeys  BerlKönig', async (t) => { tap.skip('journeys  BerlKönig', async (t) => {
const when = DateTime.fromMillis(Date.now(), { const when = DateTime.fromMillis(Date.now(), {
zone: 'Europe/Berlin', zone: 'Europe/Berlin',
locale: 'de-De', locale: 'de-De',
@ -158,7 +158,7 @@ test.skip('journeys  BerlKönig', async (t) => {
}) })
// todo: opt.walkingSpeed doesn't seem to work right now // todo: opt.walkingSpeed doesn't seem to work right now
test.skip('journeys: walkingSpeed', async (t) => { tap.skip('journeys: walkingSpeed', async (t) => {
const havelchaussee = { const havelchaussee = {
type: 'location', type: 'location',
address: 'Havelchaussee', address: 'Havelchaussee',
@ -178,7 +178,7 @@ test.skip('journeys: walkingSpeed', async (t) => {
}) })
}) })
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -191,7 +191,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test.skip('journeys  leg cycle & alternatives', async (t) => { tap.skip('journeys  leg cycle & alternatives', async (t) => {
await testLegCycleAlternatives({ await testLegCycleAlternatives({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -200,7 +200,7 @@ test.skip('journeys  leg cycle & alternatives', async (t) => {
}) })
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -213,7 +213,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(spichernstr, amrumerStr, { const res = await client.journeys(spichernstr, amrumerStr, {
results: 1, departure: when results: 1, departure: when
}) })
@ -227,7 +227,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('journeys  station to address', async (t) => { tap.test('journeys  station to address', async (t) => {
const torfstr = { const torfstr = {
type: 'location', type: 'location',
address: '13353 Berlin-Wedding, Torfstr. 17', address: '13353 Berlin-Wedding, Torfstr. 17',
@ -249,7 +249,7 @@ test('journeys  station to address', async (t) => {
t.end() t.end()
}) })
test('journeys  station to POI', async (t) => { tap.test('journeys  station to POI', async (t) => {
const atze = { const atze = {
type: 'location', type: 'location',
id: '900980720', id: '900980720',
@ -273,7 +273,7 @@ test('journeys  station to POI', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Westhafen to Wedding via Württembergalle without detour // Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine computes a detour. // is currently impossible. We check if the routing engine computes a detour.
const res = await client.journeys(westhafen, wedding, { const res = await client.journeys(westhafen, wedding, {
@ -294,7 +294,7 @@ test('journeys: via works with detour', async (t) => {
// todo: without detour test // todo: without detour test
test('departures', async (t) => { tap.test('departures', async (t) => {
const departures = await client.departures(spichernstr, { const departures = await client.departures(spichernstr, {
duration: 5, when duration: 5, when
}) })
@ -308,7 +308,7 @@ test('departures', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: spichernstr, id: spichernstr,
@ -324,7 +324,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Spichernstr. in direction of Westhafen', async (t) => { tap.test('departures at Spichernstr. in direction of Westhafen', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -337,14 +337,14 @@ test('departures at Spichernstr. in direction of Westhafen', async (t) => {
t.end() t.end()
}) })
test('departures at 7-digit station', async (t) => { tap.test('departures at 7-digit station', async (t) => {
const eisenach = '8010097' // see derhuerst/vbb-hafas#22 const eisenach = '8010097' // see derhuerst/vbb-hafas#22
await client.departures(eisenach, {when}) await client.departures(eisenach, {when})
t.pass('did not fail') t.pass('did not fail')
t.end() t.end()
}) })
test('arrivals', async (t) => { tap.test('arrivals', async (t) => {
const arrivals = await client.arrivals(spichernstr, { const arrivals = await client.arrivals(spichernstr, {
duration: 5, when duration: 5, when
}) })
@ -358,7 +358,7 @@ test('arrivals', async (t) => {
t.end() t.end()
}) })
test('nearby', async (t) => { tap.test('nearby', async (t) => {
const berlinerStr = '900000044201' const berlinerStr = '900000044201'
const landhausstr = '900000043252' const landhausstr = '900000043252'
@ -384,7 +384,7 @@ test('nearby', async (t) => {
t.end() t.end()
}) })
test('locations', async (t) => { tap.test('locations', async (t) => {
const locations = await client.locations('Alexanderplatz', {results: 20}) const locations = await client.locations('Alexanderplatz', {results: 20})
validate(t, locations, 'locations', 'locations') validate(t, locations, 'locations', 'locations')
@ -397,7 +397,7 @@ test('locations', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const s = await client.stop(spichernstr) const s = await client.stop(spichernstr)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -406,7 +406,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 52.52411, north: 52.52411,
west: 13.41002, west: 13.41002,
@ -420,7 +420,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
const torfstr17 = { const torfstr17 = {
type: 'location', type: 'location',
address: '13353 Berlin-Wedding, Torfstr. 17', address: '13353 Berlin-Wedding, Torfstr. 17',

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const assert = require('assert') const assert = require('assert')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
@ -13,7 +14,6 @@ const {
movement: _validateMovement movement: _validateMovement
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -72,7 +72,7 @@ const ettelbruck = '9258199'
const mersch = '9864348' const mersch = '9864348'
const luxembourg = '9217081' const luxembourg = '9217081'
test('journeys  Ettelbruck to Luxembourg', async (t) => { tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
const res = await client.journeys(ettelbruck, luxembourg, { const res = await client.journeys(ettelbruck, luxembourg, {
results: 4, results: 4,
departure: when, departure: when,
@ -91,7 +91,7 @@ test('journeys  Ettelbruck to Luxembourg', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -103,7 +103,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Luxembourg to 9071 Ettelbruck, Rue des Romains 4', async (t) => { tap.test('Luxembourg to 9071 Ettelbruck, Rue des Romains 4', async (t) => {
const rueDeRomain = { const rueDeRomain = {
type: 'location', type: 'location',
address: '9071 Ettelbruck, Rue des Romains 4', address: '9071 Ettelbruck, Rue des Romains 4',
@ -126,7 +126,7 @@ test('Luxembourg to 9071 Ettelbruck, Rue des Romains 4', async (t) => {
t.end() t.end()
}) })
test('Luxembourg to Centre Hospitalier du Nord', async (t) => { tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
const centreHospitalier = { const centreHospitalier = {
type: 'location', type: 'location',
id: '140701020', id: '140701020',
@ -153,7 +153,7 @@ test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
// todo: journeys: via works with detour // todo: journeys: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -166,7 +166,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip', async (t) => { tap.test('trip', async (t) => {
const { journeys } = await client.journeys(luxembourg, ettelbruck, { const { journeys } = await client.journeys(luxembourg, ettelbruck, {
results: 1, departure: when results: 1, departure: when
}) })
@ -180,7 +180,7 @@ test('trip', async (t) => {
t.end() t.end()
}) })
test('departures at Ettelbruck.', async (t) => { tap.test('departures at Ettelbruck.', async (t) => {
const departures = await client.departures(ettelbruck, { const departures = await client.departures(ettelbruck, {
duration: 20, when duration: 20, when
}) })
@ -194,7 +194,7 @@ test('departures at Ettelbruck.', async (t) => {
t.end() t.end()
}) })
test('arrivals at Ettelbruck.', async (t) => { tap.test('arrivals at Ettelbruck.', async (t) => {
const arrivals = await client.arrivals(ettelbruck, { const arrivals = await client.arrivals(ettelbruck, {
duration: 20, when duration: 20, when
}) })
@ -208,7 +208,7 @@ test('arrivals at Ettelbruck.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: ettelbruck, id: ettelbruck,
@ -226,7 +226,7 @@ test('departures with station object', async (t) => {
// todo: nearby // todo: nearby
test('locations named Mersch', async (t) => { tap.test('locations named Mersch', async (t) => {
const locations = await client.locations('Mersch', { const locations = await client.locations('Mersch', {
results: 20 results: 20
}) })
@ -244,7 +244,7 @@ test('locations named Mersch', async (t) => {
t.end() t.end()
}) })
test('stop Mersch', async (t) => { tap.test('stop Mersch', async (t) => {
const s = await client.stop(mersch) const s = await client.stop(mersch)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -253,7 +253,7 @@ test('stop Mersch', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 49.9, north: 49.9,
west: 6.05, west: 6.05,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const cmtaProfile = require('../../p/cmta') const cmtaProfile = require('../../p/cmta')
const products = require('../../p/cmta/products') const products = require('../../p/cmta/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -37,7 +38,7 @@ const broadieOaks = '2370'
const domain = '5919' const domain = '5919'
const capitol591 = '591' const capitol591 = '591'
test('journeys  Broadie Oaks to Domain', async (t) => { tap.test('journeys  Broadie Oaks to Domain', async (t) => {
const res = await client.journeys(broadieOaks, domain, { const res = await client.journeys(broadieOaks, domain, {
results: 4, results: 4,
departure: when, departure: when,
@ -56,7 +57,7 @@ test('journeys  Broadie Oaks to Domain', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -68,7 +69,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => { tap.test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => {
const someAddress = { const someAddress = {
type: 'location', type: 'location',
address: '1104 ELM ST, Austin, TX 78703', address: '1104 ELM ST, Austin, TX 78703',
@ -91,7 +92,7 @@ test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => {
t.end() t.end()
}) })
test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => { tap.test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
const wholeFoodsMarket = { const wholeFoodsMarket = {
type: 'location', type: 'location',
id: '9830513', // or `9855231` id: '9830513', // or `9855231`
@ -119,7 +120,7 @@ test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -132,7 +133,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -145,7 +146,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(broadieOaks, domain, { const res = await client.journeys(broadieOaks, domain, {
results: 1, departure: when results: 1, departure: when
}) })
@ -159,7 +160,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Broadie Oaks', async (t) => { tap.test('departures at Broadie Oaks', async (t) => {
const departures = await client.departures(broadieOaks, { const departures = await client.departures(broadieOaks, {
duration: 10, when, duration: 10, when,
}) })
@ -173,7 +174,7 @@ test('departures at Broadie Oaks', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: broadieOaks, id: broadieOaks,
@ -189,7 +190,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('arrivals at Broadie Oaks', async (t) => { tap.test('arrivals at Broadie Oaks', async (t) => {
const arrivals = await client.arrivals(broadieOaks, { const arrivals = await client.arrivals(broadieOaks, {
duration: 10, when duration: 10, when
}) })
@ -205,7 +206,7 @@ test('arrivals at Broadie Oaks', async (t) => {
// todo: nearby // todo: nearby
test('locations named "Capitol"', async (t) => { tap.test('locations named "Capitol"', async (t) => {
const locations = await client.locations('Capitol', { const locations = await client.locations('Capitol', {
results: 10 results: 10
}) })
@ -222,7 +223,7 @@ test('locations named "Capitol"', async (t) => {
t.end() t.end()
}) })
test('station Domain', async (t) => { tap.test('station Domain', async (t) => {
const s = await client.stop(domain) const s = await client.stop(domain)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -231,7 +232,7 @@ test('station Domain', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 30.240877, north: 30.240877,
west: -97.804588, west: -97.804588,
@ -245,7 +246,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,13 +1,13 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('../..') const createClient = require('../..')
const vbbProfile = require('../../p/vbb') const vbbProfile = require('../../p/vbb')
const client = createClient(vbbProfile, 'public-transport/hafas-client:test') const client = createClient(vbbProfile, 'public-transport/hafas-client:test')
test('exposes the profile', (t) => { tap.test('exposes the profile', (t) => {
t.ok(client.profile) t.ok(client.profile)
t.equal(client.profile.endpoint, vbbProfile.endpoint) t.equal(client.profile.endpoint, vbbProfile.endpoint)
t.end() t.end()

View file

@ -1,12 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const dbBusradarNrwProfile = require('../../p/db-busradar-nrw') const dbBusradarNrwProfile = require('../../p/db-busradar-nrw')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testDepartures = require('./lib/departures') const testDepartures = require('./lib/departures')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
@ -32,7 +32,7 @@ const hagenBauhaus = '3307002'
const bielefeldHbf = '8000036' const bielefeldHbf = '8000036'
const hagenVorhalle = '8000977' const hagenVorhalle = '8000977'
test('departures at Hagen Bauhaus', async (t) => { tap.test('departures at Hagen Bauhaus', async (t) => {
const departures = await client.departures(hagenBauhaus, { const departures = await client.departures(hagenBauhaus, {
duration: 120, when, duration: 120, when,
}) })
@ -46,7 +46,7 @@ test('departures at Hagen Bauhaus', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const deps = await client.departures(hagenBauhaus, { const deps = await client.departures(hagenBauhaus, {
results: 1, duration: 120, when results: 1, duration: 120, when
}) })
@ -60,7 +60,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: hagenBauhaus, id: hagenBauhaus,
@ -78,7 +78,7 @@ test('departures with station object', async (t) => {
// todo: departures at hagenBauhaus in direction of … // todo: departures at hagenBauhaus in direction of …
test('arrivals at Hagen Bauhaus', async (t) => { tap.test('arrivals at Hagen Bauhaus', async (t) => {
const arrivals = await client.arrivals(hagenBauhaus, { const arrivals = await client.arrivals(hagenBauhaus, {
duration: 120, when duration: 120, when
}) })
@ -94,7 +94,7 @@ test('arrivals at Hagen Bauhaus', async (t) => {
// todo: nearby // todo: nearby
test('locations named Vorhalle', async (t) => { tap.test('locations named Vorhalle', async (t) => {
const locations = await client.locations('vorhalle', { const locations = await client.locations('vorhalle', {
results: 10 results: 10
}) })
@ -111,7 +111,7 @@ test('locations named Vorhalle', async (t) => {
t.end() t.end()
}) })
test('station Hagen-Vorhalle', async (t) => { tap.test('station Hagen-Vorhalle', async (t) => {
const s = await client.stop(hagenVorhalle) const s = await client.stop(hagenVorhalle)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -120,7 +120,7 @@ test('station Hagen-Vorhalle', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 51.5, north: 51.5,
west: 7.2, west: 7.2,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -11,7 +12,6 @@ const {
trip: createValidateTrip trip: createValidateTrip
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -73,7 +73,7 @@ const blnTiergarten = '8089091'
const blnJannowitzbrücke = '8089019' const blnJannowitzbrücke = '8089019'
const potsdamHbf = '8012666' const potsdamHbf = '8012666'
test('journeys  Berlin Schwedter Str. to München Hbf', async (t) => { tap.test('journeys  Berlin Schwedter Str. to München Hbf', async (t) => {
const res = await client.journeys(blnSchwedterStr, münchenHbf, { const res = await client.journeys(blnSchwedterStr, münchenHbf, {
results: 4, results: 4,
departure: when, departure: when,
@ -97,7 +97,7 @@ test('journeys  Berlin Schwedter Str. to München Hbf', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -109,7 +109,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Berlin Schwedter Str. to Torfstraße 17', async (t) => { tap.test('Berlin Schwedter Str. to Torfstraße 17', async (t) => {
const torfstr = { const torfstr = {
type: 'location', type: 'location',
address: 'Torfstraße 17', address: 'Torfstraße 17',
@ -131,7 +131,7 @@ test('Berlin Schwedter Str. to Torfstraße 17', async (t) => {
t.end() t.end()
}) })
test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => { tap.test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
const atze = { const atze = {
type: 'location', type: 'location',
id: '991598902', id: '991598902',
@ -155,7 +155,7 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Westhafen to Wedding via Württembergalle without detour // Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine computes a detour. // is currently impossible. We check if the routing engine computes a detour.
const res = await client.journeys(westhafen, wedding, { const res = await client.journeys(westhafen, wedding, {
@ -177,7 +177,7 @@ test('journeys: via works with detour', async (t) => {
// todo: walkingSpeed "Berlin - Charlottenburg, Hallerstraße" -> jungfernheide // todo: walkingSpeed "Berlin - Charlottenburg, Hallerstraße" -> jungfernheide
// todo: without detour // todo: without detour
test('earlier/later journeys, Jungfernheide -> München Hbf', async (t) => { tap.test('earlier/later journeys, Jungfernheide -> München Hbf', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -190,7 +190,7 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', async (t) => {
t.end() t.end()
}) })
test.skip('journeys  leg cycle & alternatives', async (t) => { tap.skip('journeys  leg cycle & alternatives', async (t) => {
await testLegCycleAlternatives({ await testLegCycleAlternatives({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -200,7 +200,7 @@ test.skip('journeys  leg cycle & alternatives', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -213,7 +213,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(berlinHbf, münchenHbf, { const res = await client.journeys(berlinHbf, münchenHbf, {
results: 1, departure: when results: 1, departure: when
}) })
@ -236,7 +236,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Berlin Schwedter Str.', async (t) => { tap.test('departures at Berlin Schwedter Str.', async (t) => {
const departures = await client.departures(blnSchwedterStr, { const departures = await client.departures(blnSchwedterStr, {
duration: 5, when, duration: 5, when,
}) })
@ -250,7 +250,7 @@ test('departures at Berlin Schwedter Str.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: jungfernheide, id: jungfernheide,
@ -266,7 +266,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => { tap.test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -279,7 +279,7 @@ test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) =>
t.end() t.end()
}) })
test('arrivals at Berlin Schwedter Str.', async (t) => { tap.test('arrivals at Berlin Schwedter Str.', async (t) => {
const arrivals = await client.arrivals(blnSchwedterStr, { const arrivals = await client.arrivals(blnSchwedterStr, {
duration: 5, when, duration: 5, when,
}) })
@ -293,7 +293,7 @@ test('arrivals at Berlin Schwedter Str.', async (t) => {
t.end() t.end()
}) })
test('nearby Berlin Jungfernheide', async (t) => { tap.test('nearby Berlin Jungfernheide', async (t) => {
const nearby = await client.nearby({ const nearby = await client.nearby({
type: 'location', type: 'location',
latitude: 52.530273, latitude: 52.530273,
@ -317,7 +317,7 @@ test('nearby Berlin Jungfernheide', async (t) => {
t.end() t.end()
}) })
test('locations named Jungfernheide', async (t) => { tap.test('locations named Jungfernheide', async (t) => {
const locations = await client.locations('Jungfernheide', { const locations = await client.locations('Jungfernheide', {
results: 10 results: 10
}) })
@ -331,7 +331,7 @@ test('locations named Jungfernheide', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const s = await client.stop(regensburgHbf) const s = await client.stop(regensburgHbf)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -340,7 +340,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('line with additionalName', async (t) => { tap.test('line with additionalName', async (t) => {
const departures = await client.departures(potsdamHbf, { const departures = await client.departures(potsdamHbf, {
when, when,
duration: 12 * 60, // 12 minutes duration: 12 * 60, // 12 minutes
@ -350,7 +350,7 @@ test('line with additionalName', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 52.52411, north: 52.52411,
west: 13.41002, west: 13.41002,
@ -364,7 +364,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
const torfstr17 = { const torfstr17 = {
type: 'location', type: 'location',
address: 'Torfstraße 17', address: 'Torfstraße 17',
@ -383,7 +383,7 @@ test('reachableFrom', async (t) => {
t.end() t.end()
}) })
test('serverInfo works', async (t) => { tap.test('serverInfo works', async (t) => {
await testServerInfo({ await testServerInfo({
test: t, test: t,
fetchServerInfo: client.serverInfo, fetchServerInfo: client.serverInfo,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const hvvProfile = require('../../p/hvv') const hvvProfile = require('../../p/hvv')
const products = require('../../p/hvv/products') const products = require('../../p/hvv/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product') const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
@ -40,7 +40,7 @@ const altona = '20626'
// const stendal = '8010334' // const stendal = '8010334'
// const dessau = '8010077' // const dessau = '8010077'
test('journeys  Hamburg Tiefstack to Hamburg Barmbek', async (t) => { tap.test('journeys  Hamburg Tiefstack to Hamburg Barmbek', async (t) => {
const res = await client.journeys(tiefstack, barmbek, { const res = await client.journeys(tiefstack, barmbek, {
results: 4, results: 4,
departure: when, departure: when,
@ -59,7 +59,7 @@ test('journeys  Hamburg Tiefstack to Hamburg Barmbek', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -71,7 +71,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Hamburg Tiefstack to Gilbertstr. 30, Hamburg', async (t) => { tap.test('Hamburg Tiefstack to Gilbertstr. 30, Hamburg', async (t) => {
const gilbertstr30 = { const gilbertstr30 = {
type: 'location', type: 'location',
id: '970026640', id: '970026640',
@ -95,7 +95,7 @@ test('Hamburg Tiefstack to Gilbertstr. 30, Hamburg', async (t) => {
t.end() t.end()
}) })
test('Hamburg Tiefstack to Hamburger Meile', async (t) => { tap.test('Hamburg Tiefstack to Hamburger Meile', async (t) => {
const meile = { const meile = {
type: 'location', type: 'location',
id: '980001831', id: '980001831',
@ -122,7 +122,7 @@ test('Hamburg Tiefstack to Hamburger Meile', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: via works without detour // todo: via works without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -135,7 +135,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(tiefstack, barmbek, { const res = await client.journeys(tiefstack, barmbek, {
results: 1, departure: when results: 1, departure: when
}) })
@ -149,7 +149,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Hamburg Barmbek', async (t) => { tap.test('departures at Hamburg Barmbek', async (t) => {
const departures = await client.departures(barmbek, { const departures = await client.departures(barmbek, {
duration: 5, when, duration: 5, when,
}) })
@ -163,7 +163,7 @@ test('departures at Hamburg Barmbek', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: tiefstack, id: tiefstack,
@ -179,7 +179,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Barmbek in direction of Altona', async (t) => { tap.test('departures at Barmbek in direction of Altona', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -192,7 +192,7 @@ test('departures at Barmbek in direction of Altona', async (t) => {
t.end() t.end()
}) })
test('arrivals at Hamburg Barmbek', async (t) => { tap.test('arrivals at Hamburg Barmbek', async (t) => {
const arrivals = await client.arrivals(barmbek, { const arrivals = await client.arrivals(barmbek, {
duration: 5, when duration: 5, when
}) })
@ -208,7 +208,7 @@ test('arrivals at Hamburg Barmbek', async (t) => {
// todo: nearby // todo: nearby
test('locations named Elbphilharmonie', async (t) => { tap.test('locations named Elbphilharmonie', async (t) => {
const elbphilharmonie = '6242' const elbphilharmonie = '6242'
const locations = await client.locations('Elbphilharmonie', { const locations = await client.locations('Elbphilharmonie', {
results: 20 results: 20
@ -226,7 +226,7 @@ test('locations named Elbphilharmonie', async (t) => {
t.end() t.end()
}) })
test('station Hamburg Barmbek', async (t) => { tap.test('station Hamburg Barmbek', async (t) => {
const s = await client.stop(barmbek) const s = await client.stop(barmbek)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -235,7 +235,7 @@ test('station Hamburg Barmbek', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 53.569, north: 53.569,
west: 10.022, west: 10.022,

View file

@ -1,32 +0,0 @@
'use strict'
Error.stackTraceLimit = Infinity
require('./common')
require('./db')
require('./sbb')
require('./vbb')
require('./bvg')
require('./oebb')
require('./insa')
require('./nahsh')
require('./cmta')
require('./nvv')
require('./sbahn-muenchen')
require('./saarfahrplan')
require('./cfl')
require('./mobiliteit-lu')
require('./hvv')
require('./vsn')
require('./vbn')
require('./vrn')
require('./rmv')
require('./rsag')
require('./db-busradar-nrw')
require('./mobil-nrw')
require('./invg')
require('./pkp')
require('./sncb')
require('./svv')
require('./zvv')
require('./rejseplanen')

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -11,7 +12,6 @@ const {
journeyLeg: createValidateJourneyLeg, journeyLeg: createValidateJourneyLeg,
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -59,7 +59,7 @@ const stendal = '8010334'
const dessau = '8010077' const dessau = '8010077'
const universitaet = '19686' const universitaet = '19686'
test('journeys  Magdeburg Hbf to Magdeburg-Buckau', async (t) => { tap.test('journeys  Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
const res = await client.journeys(magdeburgHbf, magdeburgBuckau, { const res = await client.journeys(magdeburgHbf, magdeburgBuckau, {
results: 4, results: 4,
departure: when, departure: when,
@ -78,7 +78,7 @@ test('journeys  Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -90,7 +90,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => { tap.test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
const sternStr = { const sternStr = {
type: 'location', type: 'location',
address: 'Magdeburg - Altenstadt, Sternstraße 10', address: 'Magdeburg - Altenstadt, Sternstraße 10',
@ -113,7 +113,7 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
t.end() t.end()
}) })
test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => { tap.test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
const kloster = { const kloster = {
type: 'location', type: 'location',
id: '970012223', id: '970012223',
@ -137,7 +137,7 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Stendal // Going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Stendal
// via Dessau without detour is currently impossible. We check if the routing // via Dessau without detour is currently impossible. We check if the routing
// engine computes a detour. // engine computes a detour.
@ -159,7 +159,7 @@ test('journeys: via works with detour', async (t) => {
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -172,7 +172,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(magdeburgHbf, magdeburgBuckau, { const res = await client.journeys(magdeburgHbf, magdeburgBuckau, {
results: 1, departure: when results: 1, departure: when
}) })
@ -186,7 +186,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Magdeburg Leiterstr.', async (t) => { tap.test('departures at Magdeburg Leiterstr.', async (t) => {
const departures = await client.departures(leiterstr, { const departures = await client.departures(leiterstr, {
duration: 5, when, duration: 5, when,
}) })
@ -200,7 +200,7 @@ test('departures at Magdeburg Leiterstr.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: magdeburgHbf, id: magdeburgHbf,
@ -216,7 +216,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Leiterstr in direction of Universität', async (t) => { tap.test('departures at Leiterstr in direction of Universität', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -229,7 +229,7 @@ test('departures at Leiterstr in direction of Universität', async (t) => {
t.end() t.end()
}) })
test('arrivals at Magdeburg Leiterstr.', async (t) => { tap.test('arrivals at Magdeburg Leiterstr.', async (t) => {
const arrivals = await client.arrivals(leiterstr, { const arrivals = await client.arrivals(leiterstr, {
duration: 5, when duration: 5, when
}) })
@ -245,7 +245,7 @@ test('arrivals at Magdeburg Leiterstr.', async (t) => {
// todo: nearby // todo: nearby
test('locations named Magdeburg', async (t) => { tap.test('locations named Magdeburg', async (t) => {
const nordpark = '7480' const nordpark = '7480'
const locations = await client.locations('nordpark', { const locations = await client.locations('nordpark', {
results: 20 results: 20
@ -263,7 +263,7 @@ test('locations named Magdeburg', async (t) => {
t.end() t.end()
}) })
test('station Magdeburg-Buckau', async (t) => { tap.test('station Magdeburg-Buckau', async (t) => {
const s = await client.stop(magdeburgBuckau) const s = await client.stop(magdeburgBuckau)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -272,7 +272,7 @@ test('station Magdeburg-Buckau', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 52.148364, north: 52.148364,
west: 11.600826, west: 11.600826,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -11,7 +12,6 @@ const {
movement: createValidateMovement movement: createValidateMovement
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -55,7 +55,7 @@ const uhlandstr1 = {
longitude: 11.441138 longitude: 11.441138
} }
test('journeys  Ingolstadt Hbf to Audi Parkplatz', async (t) => { tap.test('journeys  Ingolstadt Hbf to Audi Parkplatz', async (t) => {
const telemannstr = '71801' const telemannstr = '71801'
const res = await client.journeys(ingolstadtHbf, telemannstr, { const res = await client.journeys(ingolstadtHbf, telemannstr, {
results: 4, results: 4,
@ -75,7 +75,7 @@ test('journeys  Ingolstadt Hbf to Audi Parkplatz', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -87,7 +87,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Ingolstadt Hbf to Uhlandstr. 1', async (t) => { tap.test('Ingolstadt Hbf to Uhlandstr. 1', async (t) => {
const res = await client.journeys(ingolstadtHbf, uhlandstr1, { const res = await client.journeys(ingolstadtHbf, uhlandstr1, {
results: 3, results: 3,
departure: when departure: when
@ -103,7 +103,7 @@ test('Ingolstadt Hbf to Uhlandstr. 1', async (t) => {
t.end() t.end()
}) })
test('Ingolstadt Hbf to Städtisches Freibad', async (t) => { tap.test('Ingolstadt Hbf to Städtisches Freibad', async (t) => {
const freibad = { const freibad = {
type: 'location', type: 'location',
id: '980000591', id: '980000591',
@ -130,7 +130,7 @@ test('Ingolstadt Hbf to Städtisches Freibad', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -143,7 +143,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -156,7 +156,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const {journeys} = await client.journeys(ingolstadtHbf, telemannstr, { const {journeys} = await client.journeys(ingolstadtHbf, telemannstr, {
results: 1, departure: when results: 1, departure: when
}) })
@ -170,7 +170,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Ingolstadt Hbf', async (t) => { tap.test('departures at Ingolstadt Hbf', async (t) => {
const ids = [ const ids = [
ingolstadtHbf, // station ingolstadtHbf, // station
'80301', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts" '80301', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts"
@ -184,7 +184,7 @@ test('departures at Ingolstadt Hbf', async (t) => {
validate(t, deps, 'departures', 'departures') validate(t, deps, 'departures', 'departures')
t.ok(deps.length > 0, 'must be >0 departures') t.ok(deps.length > 0, 'must be >0 departures')
// todo: move into deps validator // todo: move into deps validator
t.deepEqual(deps, deps.sort((a, b) => t.when > b.when)) t.same(deps, deps.sort((a, b) => t.when > b.when))
for (let i = 0; i < deps.length; i++) { for (let i = 0; i < deps.length; i++) {
const dep = deps[i] const dep = deps[i]
@ -194,7 +194,7 @@ test('departures at Ingolstadt Hbf', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: ingolstadtHbf, id: ingolstadtHbf,
@ -210,7 +210,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('arrivals at Ingolstadt Hbf', async (t) => { tap.test('arrivals at Ingolstadt Hbf', async (t) => {
const ids = [ const ids = [
ingolstadtHbf, // station ingolstadtHbf, // station
'80301', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts" '80301', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts"
@ -224,7 +224,7 @@ test('arrivals at Ingolstadt Hbf', async (t) => {
validate(t, arrs, 'arrivals', 'arrivals') validate(t, arrs, 'arrivals', 'arrivals')
t.ok(arrs.length > 0, 'must be >0 arrivals') t.ok(arrs.length > 0, 'must be >0 arrivals')
// todo: move into arrs validator // todo: move into arrs validator
t.deepEqual(arrs, arrs.sort((a, b) => t.when > b.when)) t.same(arrs, arrs.sort((a, b) => t.when > b.when))
for (let i = 0; i < arrs.length; i++) { for (let i = 0; i < arrs.length; i++) {
const arr = arrs[i] const arr = arrs[i]
@ -234,7 +234,7 @@ test('arrivals at Ingolstadt Hbf', async (t) => {
t.end() t.end()
}) })
test('nearby', async (t) => { tap.test('nearby', async (t) => {
const nearby = await client.nearby({ const nearby = await client.nearby({
type: 'location', type: 'location',
id: '990001921', id: '990001921',
@ -253,7 +253,7 @@ test('nearby', async (t) => {
t.end() t.end()
}) })
test('locations named "freibad"', async (t) => { tap.test('locations named "freibad"', async (t) => {
const freibadIngolstadt = '980000591' const freibadIngolstadt = '980000591'
const locations = await client.locations('freibad', { const locations = await client.locations('freibad', {
results: 5 results: 5
@ -271,7 +271,7 @@ test('locations named "freibad"', async (t) => {
t.end() t.end()
}) })
test('stop Ettinger Str.', async (t) => { tap.test('stop Ettinger Str.', async (t) => {
const ettingerStr = '18304' const ettingerStr = '18304'
const s = await client.stop(ettingerStr) const s = await client.stop(ettingerStr)
@ -281,7 +281,7 @@ test('stop Ettinger Str.', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 48.74453, north: 48.74453,
west: 11.42733, west: 11.42733,

View file

@ -17,7 +17,7 @@ const testArrivals = async (cfg) => {
} }
// todo: move into arrivals validator // todo: move into arrivals validator
t.deepEqual(arrs, arrs.sort((a, b) => t.when > b.when)) t.same(arrs, arrs.sort((a, b) => t.when > b.when))
} }
module.exports = testArrivals module.exports = testArrivals

View file

@ -17,7 +17,7 @@ const testDepartures = async (cfg) => {
} }
// todo: move into deps validator // todo: move into deps validator
t.deepEqual(deps, deps.sort((a, b) => t.when > b.when)) t.same(deps, deps.sort((a, b) => t.when > b.when))
} }
module.exports = testDepartures module.exports = testDepartures

View file

@ -20,8 +20,8 @@ const testJourneysStationToAddress = async (cfg) => {
const d = j.legs[j.legs.length - 1].destination const d = j.legs[j.legs.length - 1].destination
const n = `res.journeys[0].legs[${i}].destination` const n = `res.journeys[0].legs[${i}].destination`
t.strictEqual(d.type, 'location', n + '.type is invalid') t.equal(d.type, 'location', n + '.type is invalid')
t.strictEqual(d.address, address, n + '.address is invalid') t.equal(d.address, address, n + '.address is invalid')
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), n + '.latitude is invalid') t.ok(isRoughlyEqual(.0001, d.latitude, latitude), n + '.latitude is invalid')
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), n + '.longitude is invalid') t.ok(isRoughlyEqual(.0001, d.longitude, longitude), n + '.longitude is invalid')
} }

View file

@ -19,7 +19,7 @@ const testJourneysStationToPoi = async (cfg) => {
o = o.station o = o.station
oN += '.station' oN += '.station'
} }
t.strictEqual(o.id, fromId) t.equal(o.id, fromId)
let d = j.legs[j.legs.length - 1].destination let d = j.legs[j.legs.length - 1].destination
let dN = `res.journeys[${i}].legs[${j.legs.length - 1}].destination` let dN = `res.journeys[${i}].legs[${j.legs.length - 1}].destination`
@ -28,9 +28,9 @@ const testJourneysStationToPoi = async (cfg) => {
dN += '.station' dN += '.station'
} }
t.strictEqual(d.type, 'location', dN + '.type is invalid') t.equal(d.type, 'location', dN + '.type is invalid')
t.strictEqual(d.id, id, dN + '.id is invalid') t.equal(d.id, id, dN + '.id is invalid')
t.strictEqual(d.name, name, dN + '.name is invalid') t.equal(d.name, name, dN + '.name is invalid')
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), dN + '.latitude is invalid') t.ok(isRoughlyEqual(.0001, d.latitude, latitude), dN + '.latitude is invalid')
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), dN + '.longitude is invalid') t.ok(isRoughlyEqual(.0001, d.longitude, longitude), dN + '.longitude is invalid')
} }

View file

@ -36,7 +36,7 @@ const testReachableFrom = async (cfg) => {
} }
const sorted = results.sort((a, b) => a.duration - b.duration) const sorted = results.sort((a, b) => a.duration - b.duration)
t.deepEqual(results, sorted, 'results must be sorted by res.duration') t.same(results, sorted, 'results must be sorted by res.duration')
} }
module.exports = testReachableFrom module.exports = testReachableFrom

View file

@ -34,7 +34,7 @@ const testRefreshJourney = async (cfg) => {
const refreshed = await refreshJourney(model.refreshToken, { const refreshed = await refreshJourney(model.refreshToken, {
stopovers: false stopovers: false
}) })
t.deepEqual(simplify(refreshed), simplify(model)) t.same(simplify(refreshed), simplify(model))
} }
module.exports = testRefreshJourney module.exports = testRefreshJourney

View file

@ -5,7 +5,6 @@ const {AssertionError} = require('assert')
const {DateTime} = require('luxon') const {DateTime} = require('luxon')
const a = require('assert') const a = require('assert')
const {join} = require('path') const {join} = require('path')
const tape = require('tape')
const hour = 60 * 60 * 1000 const hour = 60 * 60 * 1000
const day = 24 * hour const day = 24 * hour
@ -51,9 +50,7 @@ if (process.env.VCR_MODE && !process.env.VCR_OFF) {
}) })
replayer.fixtureDir(join(__dirname, '..', 'fixtures')) replayer.fixtureDir(join(__dirname, '..', 'fixtures'))
} }
const test = tape
module.exports = { module.exports = {
hour, createWhen, assertValidWhen, hour, createWhen, assertValidWhen,
test,
} }

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const mobilNrwProfile = require('../../p/mobil-nrw') const mobilNrwProfile = require('../../p/mobil-nrw')
const products = require('../../p/mobil-nrw/products') const products = require('../../p/mobil-nrw/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -36,7 +37,7 @@ const soest = '8000076'
const aachenHbf = '8000001' const aachenHbf = '8000001'
const dortmundStadtgarten = '655672' const dortmundStadtgarten = '655672'
test('journeys  Soest to Aachen Hbf', async (t) => { tap.test('journeys  Soest to Aachen Hbf', async (t) => {
const res = await client.journeys(soest, aachenHbf, { const res = await client.journeys(soest, aachenHbf, {
results: 4, results: 4,
departure: when, departure: when,
@ -55,7 +56,7 @@ test('journeys  Soest to Aachen Hbf', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('Aachen Hbf to Schillingstr. 3, Dortmund', async (t) => { tap.test('Aachen Hbf to Schillingstr. 3, Dortmund', async (t) => {
const schillingstr3 = { const schillingstr3 = {
type: 'location', type: 'location',
id: '980288407', id: '980288407',
@ -79,7 +80,7 @@ test('Aachen Hbf to Schillingstr. 3, Dortmund', async (t) => {
t.end() t.end()
}) })
test('Aachen Hbf to Sportanlage Schulzentrum, Dortmund', async (t) => { tap.test('Aachen Hbf to Sportanlage Schulzentrum, Dortmund', async (t) => {
const sportanlage = { const sportanlage = {
type: 'location', type: 'location',
id: '991557725', id: '991557725',
@ -107,7 +108,7 @@ test('Aachen Hbf to Sportanlage Schulzentrum, Dortmund', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -120,7 +121,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -133,7 +134,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(soest, aachenHbf, { const res = await client.journeys(soest, aachenHbf, {
results: 1, departure: when results: 1, departure: when
}) })
@ -147,7 +148,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Soest', async (t) => { tap.test('departures at Soest', async (t) => {
const departures = await client.departures(soest, { const departures = await client.departures(soest, {
duration: 10, when, duration: 10, when,
}) })
@ -161,7 +162,7 @@ test('departures at Soest', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: soest, id: soest,
@ -177,7 +178,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('arrivals at Soest', async (t) => { tap.test('arrivals at Soest', async (t) => {
const arrivals = await client.arrivals(soest, { const arrivals = await client.arrivals(soest, {
duration: 10, when, duration: 10, when,
}) })
@ -193,7 +194,7 @@ test('arrivals at Soest', async (t) => {
// todo: nearby // todo: nearby
test('locations named "stadtgarten dortmund"', async (t) => { tap.test('locations named "stadtgarten dortmund"', async (t) => {
const locations = await client.locations('stadtgarten dortmund', { const locations = await client.locations('stadtgarten dortmund', {
results: 10, results: 10,
}) })
@ -210,7 +211,7 @@ test('locations named "stadtgarten dortmund"', async (t) => {
t.end() t.end()
}) })
test('station Aachen Hbf', async (t) => { tap.test('station Aachen Hbf', async (t) => {
const s = await client.stop(aachenHbf) const s = await client.stop(aachenHbf)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -219,7 +220,7 @@ test('station Aachen Hbf', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 51.4358, north: 51.4358,
west: 6.7625, west: 6.7625,
@ -233,7 +234,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const assert = require('assert') const assert = require('assert')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
@ -13,7 +14,6 @@ const {
movement: _validateMovement movement: _validateMovement
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -72,7 +72,7 @@ const ettelbruck = '140701016'
const mersch = '160904011' const mersch = '160904011'
const luxembourg = '200405060' const luxembourg = '200405060'
test('journeys  Ettelbruck to Luxembourg', async (t) => { tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
const res = await client.journeys(ettelbruck, luxembourg, { const res = await client.journeys(ettelbruck, luxembourg, {
results: 4, results: 4,
departure: when, departure: when,
@ -91,7 +91,7 @@ test('journeys  Ettelbruck to Luxembourg', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -103,7 +103,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Luxembourg to Ettelbruck, Rue des Romains 4', async (t) => { tap.test('Luxembourg to Ettelbruck, Rue des Romains 4', async (t) => {
const rueDeRomain = { const rueDeRomain = {
type: 'location', type: 'location',
address: 'Ettelbruck, Rue des Romains 4', address: 'Ettelbruck, Rue des Romains 4',
@ -126,7 +126,7 @@ test('Luxembourg to Ettelbruck, Rue des Romains 4', async (t) => {
t.end() t.end()
}) })
test('Luxembourg to Centre Hospitalier du Nord', async (t) => { tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
const centreHospitalier = { const centreHospitalier = {
type: 'location', type: 'location',
id: '140701020', id: '140701020',
@ -153,7 +153,7 @@ test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
// todo: journeys: via works with detour // todo: journeys: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -166,7 +166,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip', async (t) => { tap.test('trip', async (t) => {
const { journeys } = await client.journeys(luxembourg, ettelbruck, { const { journeys } = await client.journeys(luxembourg, ettelbruck, {
results: 1, departure: when results: 1, departure: when
}) })
@ -180,7 +180,7 @@ test('trip', async (t) => {
t.end() t.end()
}) })
test('departures at Ettelbruck.', async (t) => { tap.test('departures at Ettelbruck.', async (t) => {
const departures = await client.departures(ettelbruck, { const departures = await client.departures(ettelbruck, {
duration: 20, when duration: 20, when
}) })
@ -194,7 +194,7 @@ test('departures at Ettelbruck.', async (t) => {
t.end() t.end()
}) })
test('arrivals at Ettelbruck.', async (t) => { tap.test('arrivals at Ettelbruck.', async (t) => {
const arrivals = await client.arrivals(ettelbruck, { const arrivals = await client.arrivals(ettelbruck, {
duration: 20, when duration: 20, when
}) })
@ -208,7 +208,7 @@ test('arrivals at Ettelbruck.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: ettelbruck, id: ettelbruck,
@ -226,7 +226,7 @@ test('departures with station object', async (t) => {
// todo: nearby // todo: nearby
test('locations named Mersch', async (t) => { tap.test('locations named Mersch', async (t) => {
const locations = await client.locations('Mersch', { const locations = await client.locations('Mersch', {
results: 20 results: 20
}) })
@ -243,7 +243,7 @@ test('locations named Mersch', async (t) => {
t.end() t.end()
}) })
test('stop Mersch', async (t) => { tap.test('stop Mersch', async (t) => {
const s = await client.stop(mersch) const s = await client.stop(mersch)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -252,7 +252,7 @@ test('stop Mersch', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 49.9, north: 49.9,
west: 6.05, west: 6.05,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -11,7 +12,6 @@ const {
station: createValidateStation station: createValidateStation
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -73,7 +73,7 @@ const ellerbekerMarkt = '9049027'
const seefischmarkt = '9049245' const seefischmarkt = '9049245'
const kielRaeucherei = '9049217' const kielRaeucherei = '9049217'
test('journeys  Kiel Hbf to Flensburg', async (t) => { tap.test('journeys  Kiel Hbf to Flensburg', async (t) => {
const res = await client.journeys(kielHbf, flensburg, { const res = await client.journeys(kielHbf, flensburg, {
results: 4, results: 4,
departure: when, departure: when,
@ -100,7 +100,7 @@ test('journeys  Kiel Hbf to Flensburg', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -112,7 +112,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Kiel Hbf to Berliner Str. 80, Husum', async (t) => { tap.test('Kiel Hbf to Berliner Str. 80, Husum', async (t) => {
const berlinerStr = { const berlinerStr = {
type: 'location', type: 'location',
address: 'Husum, Berliner Straße 80', address: 'Husum, Berliner Straße 80',
@ -134,7 +134,7 @@ test('Kiel Hbf to Berliner Str. 80, Husum', async (t) => {
t.end() t.end()
}) })
test('Kiel Hbf to Holstentor', async (t) => { tap.test('Kiel Hbf to Holstentor', async (t) => {
const holstentor = { const holstentor = {
type: 'location', type: 'location',
id: '970003168', id: '970003168',
@ -158,7 +158,7 @@ test('Kiel Hbf to Holstentor', async (t) => {
t.end() t.end()
}) })
test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => { tap.test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => {
const res = await client.journeys(husum, luebeckHbf, { const res = await client.journeys(husum, luebeckHbf, {
via: kielHbf, via: kielHbf,
results: 1, results: 1,
@ -179,7 +179,7 @@ test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => {
t.end() t.end()
}) })
test('earlier/later journeys, Kiel Hbf -> Flensburg', async (t) => { tap.test('earlier/later journeys, Kiel Hbf -> Flensburg', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -192,7 +192,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -208,7 +208,7 @@ test('refreshJourney', async (t) => {
// todo: with detour test // todo: with detour test
// todo: without detour test // todo: without detour test
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(flensburg, husum, { const res = await client.journeys(flensburg, husum, {
results: 1, departure: when results: 1, departure: when
}) })
@ -222,7 +222,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Kiel Räucherei', async (t) => { tap.test('departures at Kiel Räucherei', async (t) => {
const departures = await client.departures(kielRaeucherei, { const departures = await client.departures(kielRaeucherei, {
duration: 30, when, duration: 30, when,
}) })
@ -236,7 +236,7 @@ test('departures at Kiel Räucherei', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: kielHbf, id: kielHbf,
@ -252,7 +252,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => { tap.test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -265,7 +265,7 @@ test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) =>
t.end() t.end()
}) })
test('arrivals at Kiel Räucherei', async (t) => { tap.test('arrivals at Kiel Räucherei', async (t) => {
const arrivals = await client.arrivals(kielRaeucherei, { const arrivals = await client.arrivals(kielRaeucherei, {
duration: 30, when duration: 30, when
}) })
@ -279,7 +279,7 @@ test('arrivals at Kiel Räucherei', async (t) => {
t.end() t.end()
}) })
test('nearby Kiel Hbf', async (t) => { tap.test('nearby Kiel Hbf', async (t) => {
const kielHbfPosition = { const kielHbfPosition = {
type: 'location', type: 'location',
latitude: 54.314982, latitude: 54.314982,
@ -302,7 +302,7 @@ test('nearby Kiel Hbf', async (t) => {
t.end() t.end()
}) })
test('locations named "Kiel Rathaus"', async (t) => { tap.test('locations named "Kiel Rathaus"', async (t) => {
const kielRathaus = '9049200' const kielRathaus = '9049200'
const locations = await client.locations('Kiel Rathaus', { const locations = await client.locations('Kiel Rathaus', {
results: 15 results: 15
@ -318,7 +318,7 @@ test('locations named "Kiel Rathaus"', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const s = await client.stop(kielHbf) const s = await client.stop(kielHbf)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -327,7 +327,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 54.4, north: 54.4,
west: 10.0, west: 10.0,
@ -354,7 +354,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
const berlinerStr = { const berlinerStr = {
type: 'location', type: 'location',
address: 'Husum, Berliner Straße 80', address: 'Husum, Berliner Straße 80',

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const nvvProfile = require('../../p/nvv') const nvvProfile = require('../../p/nvv')
const products = require('../../p/nvv/products') const products = require('../../p/nvv/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product') const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
@ -39,7 +39,7 @@ const auestadion = '2200042'
const weigelstr = '2200056' const weigelstr = '2200056'
const friedrichsplatz = '2200006' const friedrichsplatz = '2200006'
test('journeys  Kassel Scheidemannplatz to Kassel Auestadion', async (t) => { tap.test('journeys  Kassel Scheidemannplatz to Kassel Auestadion', async (t) => {
const res = await client.journeys(scheidemannplatz, auestadion, { const res = await client.journeys(scheidemannplatz, auestadion, {
results: 4, results: 4,
departure: when, departure: when,
@ -58,7 +58,7 @@ test('journeys  Kassel Scheidemannplatz to Kassel Auestadion', async (t) =>
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -70,7 +70,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Kassel Scheidemannplatz to Heckerstraße 2', async (t) => { tap.test('Kassel Scheidemannplatz to Heckerstraße 2', async (t) => {
const heckerstr2 = { const heckerstr2 = {
type: 'location', type: 'location',
id: '990100251', id: '990100251',
@ -94,7 +94,7 @@ test('Kassel Scheidemannplatz to Heckerstraße 2', async (t) => {
t.end() t.end()
}) })
test('Kassel Scheidemannplatz to Grimmwelt', async (t) => { tap.test('Kassel Scheidemannplatz to Grimmwelt', async (t) => {
const grimmwelt = { const grimmwelt = {
type: 'location', type: 'location',
id: '1500490', id: '1500490',
@ -118,7 +118,7 @@ test('Kassel Scheidemannplatz to Grimmwelt', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Scheidemannplatz to Rathaus/Fünffensterstr. via Kassel Wilhelmshöhe // Going from Scheidemannplatz to Rathaus/Fünffensterstr. via Kassel Wilhelmshöhe
// implies a detour. We check if the routing engine computes a detour. // implies a detour. We check if the routing engine computes a detour.
const rathausFünffensterstr = '2200436' const rathausFünffensterstr = '2200436'
@ -141,7 +141,7 @@ test('journeys: via works with detour', async (t) => {
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -154,7 +154,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(scheidemannplatz, auestadion, { const res = await client.journeys(scheidemannplatz, auestadion, {
results: 1, departure: when results: 1, departure: when
}) })
@ -168,7 +168,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Kassel Auestadion.', async (t) => { tap.test('departures at Kassel Auestadion.', async (t) => {
const departures = await client.departures(auestadion, { const departures = await client.departures(auestadion, {
duration: 11, when, duration: 11, when,
}) })
@ -182,7 +182,7 @@ test('departures at Kassel Auestadion.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: auestadion, id: auestadion,
@ -198,7 +198,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Auestadion in direction of Friedrichsplatz', async (t) => { tap.test('departures at Auestadion in direction of Friedrichsplatz', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -211,7 +211,7 @@ test('departures at Auestadion in direction of Friedrichsplatz', async (t) => {
t.end() t.end()
}) })
test('arrivals at Kassel Weigelstr.', async (t) => { tap.test('arrivals at Kassel Weigelstr.', async (t) => {
const arrivals = await client.arrivals(weigelstr, { const arrivals = await client.arrivals(weigelstr, {
duration: 5, when duration: 5, when
}) })
@ -227,7 +227,7 @@ test('arrivals at Kassel Weigelstr.', async (t) => {
// todo: nearby // todo: nearby
test('locations named Auestadion', async (t) => { tap.test('locations named Auestadion', async (t) => {
const locations = await client.locations('auestadion', {results: 10}) const locations = await client.locations('auestadion', {results: 10})
validate(t, locations, 'locations', 'locations') validate(t, locations, 'locations', 'locations')
@ -240,7 +240,7 @@ test('locations named Auestadion', async (t) => {
t.end() t.end()
}) })
test('station Auestadion', async (t) => { tap.test('station Auestadion', async (t) => {
const s = await client.stop(auestadion) const s = await client.stop(auestadion)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -249,7 +249,7 @@ test('station Auestadion', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 51.320153, north: 51.320153,
west: 9.458359, west: 9.458359,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const validateLine = require('validate-fptf/line') const validateLine = require('validate-fptf/line')
@ -12,7 +13,6 @@ const {
stop: validateStop stop: validateStop
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -62,7 +62,7 @@ const wienRenngasse = '1390186'
const wienKarlsplatz = '1390461' const wienKarlsplatz = '1390461'
const wienPilgramgasse = '1390562' const wienPilgramgasse = '1390562'
test('journeys  Salzburg Hbf to Wien Westbahnhof', async (t) => { tap.test('journeys  Salzburg Hbf to Wien Westbahnhof', async (t) => {
const res = await client.journeys(salzburgHbf, wienFickeystr, { const res = await client.journeys(salzburgHbf, wienFickeystr, {
results: 4, results: 4,
departure: when, departure: when,
@ -87,7 +87,7 @@ test('journeys  Salzburg Hbf to Wien Westbahnhof', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -99,7 +99,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Salzburg Hbf to 1220 Wien, Fischerstrand 7', async (t) => { tap.test('Salzburg Hbf to 1220 Wien, Fischerstrand 7', async (t) => {
const wagramerStr = { const wagramerStr = {
type: 'location', type: 'location',
address: '1220 Wien, Fischerstrand 7', address: '1220 Wien, Fischerstrand 7',
@ -121,7 +121,7 @@ test('Salzburg Hbf to 1220 Wien, Fischerstrand 7', async (t) => {
t.end() t.end()
}) })
test('Salzburg Hbf to Uni Wien', async (t) => { tap.test('Salzburg Hbf to Uni Wien', async (t) => {
const uniWien = { const uniWien = {
type: 'location', type: 'location',
id: '970076515', id: '970076515',
@ -144,7 +144,7 @@ test('Salzburg Hbf to Uni Wien', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Stephansplatz to Schottenring via Donauinsel without detour // Going from Stephansplatz to Schottenring via Donauinsel without detour
// is currently impossible. We check if the routing engine computes a detour. // is currently impossible. We check if the routing engine computes a detour.
const stephansplatz = '1390167' const stephansplatz = '1390167'
@ -167,7 +167,7 @@ test('journeys: via works with detour', async (t) => {
t.end() t.end()
}) })
test('journeys: via works without detour', async (t) => { tap.test('journeys: via works without detour', async (t) => {
// When going from Karlsplatz to Praterstern via Museumsquartier, there is // When going from Karlsplatz to Praterstern via Museumsquartier, there is
// *no need* to change trains / no need for a "detour". // *no need* to change trains / no need for a "detour".
const karlsplatz = '1390461' const karlsplatz = '1390461'
@ -202,7 +202,7 @@ test('journeys: via works without detour', async (t) => {
t.end() t.end()
}) })
test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', async (t) => { tap.test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -215,7 +215,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -228,7 +228,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(wienWestbahnhof, muenchenHbf, { const res = await client.journeys(wienWestbahnhof, muenchenHbf, {
results: 1, departure: when results: 1, departure: when
}) })
@ -242,7 +242,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Wien Leibenfrostgasse', async (t) => { tap.test('departures at Wien Leibenfrostgasse', async (t) => {
const wienLeibenfrostgasse = '1390469' const wienLeibenfrostgasse = '1390469'
const ids = [ const ids = [
wienLeibenfrostgasse, // station wienLeibenfrostgasse, // station
@ -257,7 +257,7 @@ test('departures at Wien Leibenfrostgasse', async (t) => {
validate(t, deps, 'departures', 'departures') validate(t, deps, 'departures', 'departures')
t.ok(deps.length > 0, 'must be >0 departures') t.ok(deps.length > 0, 'must be >0 departures')
// todo: move into deps validator // todo: move into deps validator
t.deepEqual(deps, deps.sort((a, b) => t.when > b.when)) t.same(deps, deps.sort((a, b) => t.when > b.when))
for (let i = 0; i < deps.length; i++) { for (let i = 0; i < deps.length; i++) {
const dep = deps[i] const dep = deps[i]
@ -267,7 +267,7 @@ test('departures at Wien Leibenfrostgasse', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: salzburgHbf, id: salzburgHbf,
@ -283,7 +283,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Karlsplatz in direction of Pilgramgasse', async (t) => { tap.test('departures at Karlsplatz in direction of Pilgramgasse', async (t) => {
const subStops = (await client.stop(wienPilgramgasse, { const subStops = (await client.stop(wienPilgramgasse, {
subStops: true, entrances: false, subStops: true, entrances: false,
})).stops || [] })).stops || []
@ -302,7 +302,7 @@ test('departures at Karlsplatz in direction of Pilgramgasse', async (t) => {
// todo: arrivals // todo: arrivals
test('nearby Salzburg Hbf', async (t) => { tap.test('nearby Salzburg Hbf', async (t) => {
const nearby = await client.nearby({ const nearby = await client.nearby({
type: 'location', type: 'location',
longitude: 13.045604, longitude: 13.045604,
@ -325,7 +325,7 @@ test('nearby Salzburg Hbf', async (t) => {
t.end() t.end()
}) })
test('locations named Salzburg', async (t) => { tap.test('locations named Salzburg', async (t) => {
const salzburgVolksgarten = '591161' const salzburgVolksgarten = '591161'
const locations = await client.locations('Salzburg volksgarten', { const locations = await client.locations('Salzburg volksgarten', {
results: 20 results: 20
@ -343,7 +343,7 @@ test('locations named Salzburg', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const loc = await client.stop(wienRenngasse) const loc = await client.stop(wienRenngasse)
// todo: find a way to always get products from the API // todo: find a way to always get products from the API
@ -367,7 +367,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('radar Salzburg', async (t) => { tap.test('radar Salzburg', async (t) => {
let vehicles = await client.radar({ let vehicles = await client.radar({
north: 47.827203, north: 47.827203,
west: 13.001261, west: 13.001261,

View file

@ -1,5 +1,7 @@
'use strict' 'use strict'
const tap = require('tap')
const { createWhen } = require('./lib/util') const { createWhen } = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const pkpProfile = require('../../p/pkp') const pkpProfile = require('../../p/pkp')
@ -10,7 +12,6 @@ const {
movement: _validateMovement movement: _validateMovement
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
const testReachableFrom = require('./lib/reachable-from') const testReachableFrom = require('./lib/reachable-from')
@ -69,7 +70,7 @@ const filharmonia = {
poi: true poi: true
} }
test.skip('journeys Wrocław Główny to Kraków Główny', async (t) => { tap.skip('journeys Wrocław Główny to Kraków Główny', async (t) => {
const res = await client.journeys(wrocławGł, krakówGł, { const res = await client.journeys(wrocławGł, krakówGł, {
results: 4, results: 4,
departure: when, departure: when,
@ -89,7 +90,7 @@ test.skip('journeys Wrocław Główny to Kraków Główny', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test.skip('trip details', async (t) => { tap.skip('trip details', async (t) => {
const res = await client.journeys(wrocławGł, krakówGł, { const res = await client.journeys(wrocławGł, krakówGł, {
results: 1, departure: when results: 1, departure: when
}) })
@ -103,7 +104,7 @@ test.skip('trip details', async (t) => {
t.end() t.end()
}) })
test.skip('arrivals at Kraków Główny', async (t) => { tap.skip('arrivals at Kraków Główny', async (t) => {
const arrivals = await client.arrivals(krakówGł, { const arrivals = await client.arrivals(krakówGł, {
duration: 10, when duration: 10, when
}) })
@ -116,7 +117,7 @@ test.skip('arrivals at Kraków Główny', async (t) => {
t.end() t.end()
}) })
test.skip('nearby', async (t) => { tap.skip('nearby', async (t) => {
const nearby = await client.nearby(dworcowa100, { distance: 500 }) const nearby = await client.nearby(dworcowa100, { distance: 500 })
validate(t, nearby, 'locations', 'nearby') validate(t, nearby, 'locations', 'nearby')
@ -127,7 +128,7 @@ test.skip('nearby', async (t) => {
t.end() t.end()
}) })
test.skip('radar', async (t) => { tap.skip('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 48.74453, north: 48.74453,
west: 11.42733, west: 11.42733,
@ -141,7 +142,7 @@ test.skip('radar', async (t) => {
t.end() t.end()
}) })
test.skip('reachableFrom', async (t) => { tap.skip('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const assert = require('assert') const assert = require('assert')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const rejseplanenProfile = require('../../p/rejseplanen') const rejseplanenProfile = require('../../p/rejseplanen')
const products = require('../../p/rejseplanen/products') const products = require('../../p/rejseplanen/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product') const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
@ -32,7 +32,7 @@ const næstved = '8600810'
const randers = '8600040' const randers = '8600040'
const aalborg = '8600020' const aalborg = '8600020'
test('journeys  Næstved to Aalborg', async (t) => { tap.test('journeys  Næstved to Aalborg', async (t) => {
const res = await client.journeys(næstved, aalborg, { const res = await client.journeys(næstved, aalborg, {
results: 4, results: 4,
departure: when, departure: when,
@ -51,7 +51,7 @@ test('journeys  Næstved to Aalborg', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -63,7 +63,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Randers to Møllegade 3, København', async (t) => { tap.test('Randers to Møllegade 3, København', async (t) => {
const møllegade3 = { const møllegade3 = {
type: 'location', type: 'location',
id: '901011579', id: '901011579',
@ -89,7 +89,7 @@ test('Randers to Møllegade 3, København', async (t) => {
// todo: journeys: via works with detour // todo: journeys: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -102,7 +102,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip', async (t) => { tap.test('trip', async (t) => {
const { journeys } = await client.journeys(aalborg, næstved, { const { journeys } = await client.journeys(aalborg, næstved, {
results: 1, departure: when, results: 1, departure: when,
}) })
@ -116,7 +116,7 @@ test('trip', async (t) => {
t.end() t.end()
}) })
test('departures at Næstved.', async (t) => { tap.test('departures at Næstved.', async (t) => {
const departures = await client.departures(næstved, { const departures = await client.departures(næstved, {
duration: 20, when, duration: 20, when,
}) })
@ -130,7 +130,7 @@ test('departures at Næstved.', async (t) => {
t.end() t.end()
}) })
test('arrivals at Næstved.', async (t) => { tap.test('arrivals at Næstved.', async (t) => {
const arrivals = await client.arrivals(næstved, { const arrivals = await client.arrivals(næstved, {
duration: 20, when duration: 20, when
}) })
@ -146,7 +146,7 @@ test('arrivals at Næstved.', async (t) => {
// todo: nearby // todo: nearby
test('locations named "næstved"', async (t) => { tap.test('locations named "næstved"', async (t) => {
const locations = await client.locations('næstved', { const locations = await client.locations('næstved', {
results: 20, results: 20,
}) })
@ -164,7 +164,7 @@ test('locations named "næstved"', async (t) => {
t.end() t.end()
}) })
test('stop Næstved', async (t) => { tap.test('stop Næstved', async (t) => {
const s = await client.stop(næstved) const s = await client.stop(næstved)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -173,7 +173,7 @@ test('stop Næstved', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 55.695, north: 55.695,
west: 12.498, west: 12.498,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const rmvProfile = require('../../p/rmv') const rmvProfile = require('../../p/rmv')
const products = require('../../p/rmv/products') const products = require('../../p/rmv/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testRefreshJourney = require('./lib/refresh-journey') const testRefreshJourney = require('./lib/refresh-journey')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
@ -30,7 +31,7 @@ const client = createClient(rmvProfile, 'public-transport/hafas-client:test')
const frankfurtOstendstr = '3000525' const frankfurtOstendstr = '3000525'
const wiesbadenHbf = '3006907' const wiesbadenHbf = '3006907'
test('journeys  Frankfurt Ostendstr. to Wiesbaden Hbf', async (t) => { tap.test('journeys  Frankfurt Ostendstr. to Wiesbaden Hbf', async (t) => {
const res = await client.journeys(frankfurtOstendstr, wiesbadenHbf, { const res = await client.journeys(frankfurtOstendstr, wiesbadenHbf, {
results: 4, results: 4,
departure: when, departure: when,
@ -50,7 +51,7 @@ test('journeys  Frankfurt Ostendstr. to Wiesbaden Hbf', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(frankfurtOstendstr, wiesbadenHbf, { const res = await client.journeys(frankfurtOstendstr, wiesbadenHbf, {
results: 1, departure: when results: 1, departure: when
}) })
@ -64,20 +65,20 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('arrivals at Wiesbaden Hbf', async (t) => { tap.test('arrivals at Wiesbaden Hbf', async (t) => {
const arrivals = await client.arrivals(wiesbadenHbf, { const arrivals = await client.arrivals(wiesbadenHbf, {
duration: 10, when duration: 10, when
}) })
validate(t, arrivals, 'arrivals', 'arrivals') validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals') t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when)) t.same(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
// todo: nearby // todo: nearby
test.skip('radar', async (t) => { tap.skip('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 53.090516, north: 53.090516,
west: 8.750106, west: 8.750106,
@ -91,7 +92,7 @@ test.skip('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const rsagProfile = require('../../p/rsag') const rsagProfile = require('../../p/rsag')
const products = require('../../p/rsag/products') const products = require('../../p/rsag/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys') const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
const testRefreshJourney = require('./lib/refresh-journey') const testRefreshJourney = require('./lib/refresh-journey')
@ -32,7 +33,7 @@ const sternwarte = '704956'
const sternwarte2 = '708539' const sternwarte2 = '708539'
const weißesKreuz = '708573' const weißesKreuz = '708573'
test('journeys  Platz der Jugend to Weißes Kreuz', async (t) => { tap.test('journeys  Platz der Jugend to Weißes Kreuz', async (t) => {
const res = await client.journeys(sternwarte, weißesKreuz, { const res = await client.journeys(sternwarte, weißesKreuz, {
results: 4, results: 4,
departure: when, departure: when,
@ -52,7 +53,7 @@ test('journeys  Platz der Jugend to Weißes Kreuz', async (t) => {
// todo: journeys, walkingSpeed // todo: journeys, walkingSpeed
// todo: via works with detour // todo: via works with detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -65,7 +66,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -78,20 +79,20 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('arrivals at Platz der Jugend', async (t) => { tap.test('arrivals at Platz der Jugend', async (t) => {
const arrivals = await client.arrivals(sternwarte, { const arrivals = await client.arrivals(sternwarte, {
duration: 30, when duration: 30, when
}) })
validate(t, arrivals, 'arrivals', 'arrivals') validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals') t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when)) t.same(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
// todo: nearby // todo: nearby
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 54.116968, north: 54.116968,
west: 12.029738, west: 12.029738,
@ -105,7 +106,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const { createWhen } = require('./lib/util') const { createWhen } = require('./lib/util')
@ -11,7 +12,6 @@ const {
stop: validateStop stop: validateStop
} = require('./lib/validators') } = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -69,7 +69,7 @@ const thomasMannStr = {
// @todo prices/tickets // @todo prices/tickets
// @todo journeys, only one product // @todo journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -81,7 +81,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => { tap.test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
const res = await client.journeys(saarbrueckenHbf, thomasMannStr, { const res = await client.journeys(saarbrueckenHbf, thomasMannStr, {
results: 3, results: 3,
departure: when departure: when
@ -97,7 +97,7 @@ test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
t.end() t.end()
}) })
test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => { tap.test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
const schlossberghoehlen = { const schlossberghoehlen = {
type: 'location', type: 'location',
id: '9000185', id: '9000185',
@ -120,7 +120,7 @@ test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
t.end() t.end()
}) })
test.skip('journeys: via works with detour', async (t) => { tap.skip('journeys: via works with detour', async (t) => {
// Going from Stephansplatz to Schottenring via Donauinsel without detour // Going from Stephansplatz to Schottenring via Donauinsel without detour
// is currently impossible. We check if the routing engine computes a detour. // is currently impossible. We check if the routing engine computes a detour.
const stephansplatz = '1390167' const stephansplatz = '1390167'
@ -145,7 +145,7 @@ test.skip('journeys: via works with detour', async (t) => {
// todo: journeys: via works without detour // todo: journeys: via works without detour
test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', async (t) => { tap.test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -158,7 +158,7 @@ test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(saarlouisHbf, metzVille, { const res = await client.journeys(saarlouisHbf, metzVille, {
results: 1, departure: when results: 1, departure: when
}) })
@ -172,7 +172,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures', async (t) => { tap.test('departures', async (t) => {
const departures = await client.departures(saarbrueckenUhlandstr, { const departures = await client.departures(saarbrueckenUhlandstr, {
duration: 5, when duration: 5, when
}) })
@ -191,11 +191,11 @@ test('departures', async (t) => {
} }
// todo: move into deps validator // todo: move into deps validator
t.deepEqual(departures, departures.sort((a, b) => t.when > b.when)) t.same(departures, departures.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
test('departures with stop object', async (t) => { tap.test('departures with stop object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'stop', type: 'stop',
id: '8000323', id: '8000323',
@ -211,7 +211,7 @@ test('departures with stop object', async (t) => {
t.end() t.end()
}) })
test('departures at Uhlandstr., Saarbrücken in direction of Landwehrplatz', async (t) => { tap.test('departures at Uhlandstr., Saarbrücken in direction of Landwehrplatz', async (t) => {
const saarbrueckenLandwehrplatz = '10606' const saarbrueckenLandwehrplatz = '10606'
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
@ -227,7 +227,7 @@ test('departures at Uhlandstr., Saarbrücken in direction of Landwehrplatz', asy
// todo: arrivals // todo: arrivals
test('nearby Saarbrücken Hbf', async (t) => { tap.test('nearby Saarbrücken Hbf', async (t) => {
const nearby = await client.nearby({ const nearby = await client.nearby({
type: 'location', type: 'location',
latitude: 49.241066, latitude: 49.241066,
@ -250,7 +250,7 @@ test('nearby Saarbrücken Hbf', async (t) => {
t.end() t.end()
}) })
test('locations named Saarbrücken', async (t) => { tap.test('locations named Saarbrücken', async (t) => {
const aufDerWerthBürgerpark = '10204' const aufDerWerthBürgerpark = '10204'
const locations = await client.locations('bürgerpark', { const locations = await client.locations('bürgerpark', {
results: 20 results: 20
@ -268,7 +268,7 @@ test('locations named Saarbrücken', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const s = await client.stop(saarbrueckenUhlandstr) const s = await client.stop(saarbrueckenUhlandstr)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -277,7 +277,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 49.27, north: 49.27,
west: 6.97, west: 6.97,

View file

@ -1,12 +1,13 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const sMunichProfile = require('../../p/sbahn-muenchen') const sMunichProfile = require('../../p/sbahn-muenchen')
const products = require('../../p/sbahn-muenchen/products') const products = require('../../p/sbahn-muenchen/products')
const {movement: _validateMovement} = require('./lib/validators') const {movement: _validateMovement} = require('./lib/validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -59,7 +60,7 @@ const poetschnerstr = {
longitude: 11.531695 longitude: 11.531695
} }
test('journeys  Mittersendling to Karl-Theodor-Straße', async (t) => { tap.test('journeys  Mittersendling to Karl-Theodor-Straße', async (t) => {
const res = await client.journeys(mittersendling, karlTheodorStr, { const res = await client.journeys(mittersendling, karlTheodorStr, {
results: 4, results: 4,
departure: when, departure: when,
@ -78,7 +79,7 @@ test('journeys  Mittersendling to Karl-Theodor-Straße', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -90,7 +91,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => { tap.test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => {
const res = await client.journeys(karlTheodorStr, poetschnerstr, { const res = await client.journeys(karlTheodorStr, poetschnerstr, {
results: 3, results: 3,
departure: when departure: when
@ -106,7 +107,7 @@ test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => {
t.end() t.end()
}) })
test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => { tap.test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
const hofbraeuhaus = { const hofbraeuhaus = {
type: 'location', type: 'location',
id: '970006201', id: '970006201',
@ -134,7 +135,7 @@ test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -147,7 +148,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -160,7 +161,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(mittersendling, karlTheodorStr, { const res = await client.journeys(mittersendling, karlTheodorStr, {
results: 1, departure: when results: 1, departure: when
}) })
@ -174,7 +175,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Dietlindenstraße', async (t) => { tap.test('departures at Dietlindenstraße', async (t) => {
const dietlindenstr = '624391' const dietlindenstr = '624391'
const departures = await client.departures(dietlindenstr, { const departures = await client.departures(dietlindenstr, {
duration: 10, when, duration: 10, when,
@ -189,7 +190,7 @@ test('departures at Dietlindenstraße', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: mittersendling, id: mittersendling,
@ -205,7 +206,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('arrivals at Karl-Theodor-Straße', async (t) => { tap.test('arrivals at Karl-Theodor-Straße', async (t) => {
const arrivals = await client.arrivals(karlTheodorStr, { const arrivals = await client.arrivals(karlTheodorStr, {
duration: 10, when, duration: 10, when,
}) })
@ -221,7 +222,7 @@ test('arrivals at Karl-Theodor-Straße', async (t) => {
// todo: nearby // todo: nearby
test('locations named "Nationaltheater"', async (t) => { tap.test('locations named "Nationaltheater"', async (t) => {
const nationaltheater = '624639' const nationaltheater = '624639'
const locations = await client.locations('Nationaltheater', { const locations = await client.locations('Nationaltheater', {
results: 10 results: 10
@ -239,7 +240,7 @@ test('locations named "Nationaltheater"', async (t) => {
t.end() t.end()
}) })
test('station Karl-Theodor-Straße', async (t) => { tap.test('station Karl-Theodor-Straße', async (t) => {
const s = await client.stop(karlTheodorStr) const s = await client.stop(karlTheodorStr)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -248,7 +249,7 @@ test('station Karl-Theodor-Straße', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 48.145121, north: 48.145121,
west: 11.543736, west: 11.543736,
@ -262,7 +263,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const sbbProfile = require('../../p/sbb') const sbbProfile = require('../../p/sbb')
const products = require('../../p/sbb/products') const products = require('../../p/sbb/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -41,7 +42,7 @@ const oetwilAmSee = {
latitude: 47.278873, longitude: 8.726485, latitude: 47.278873, longitude: 8.726485,
} }
test('journeys  Basel to Lausanne', async (t) => { tap.test('journeys  Basel to Lausanne', async (t) => {
const res = await client.journeys(basel, lausanne, { const res = await client.journeys(basel, lausanne, {
results: 4, results: 4,
departure: when, departure: when,
@ -58,7 +59,7 @@ test('journeys  Basel to Lausanne', async (t) => {
t.end() t.end()
}) })
test('Lausanne to 8618 Oetwil am See, Morgental', async (t) => { tap.test('Lausanne to 8618 Oetwil am See, Morgental', async (t) => {
const res = await client.journeys(lausanne, oetwilAmSee, { const res = await client.journeys(lausanne, oetwilAmSee, {
results: 3, results: 3,
departure: when, departure: when,
@ -74,7 +75,7 @@ test('Lausanne to 8618 Oetwil am See, Morgental', async (t) => {
t.end() t.end()
}) })
test('Lausanne to ETH Institut für Pflanzenwissenschaften', async (t) => { tap.test('Lausanne to ETH Institut für Pflanzenwissenschaften', async (t) => {
const ethPflanzenwissenschaften = { const ethPflanzenwissenschaften = {
type: 'location', type: 'location',
id: '980008611', id: '980008611',
@ -99,7 +100,7 @@ test('Lausanne to ETH Institut für Pflanzenwissenschaften', async (t) => {
// todo: via works with detour // todo: via works with detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -112,7 +113,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -125,7 +126,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(baselSBB, lausanne, { const res = await client.journeys(baselSBB, lausanne, {
results: 1, departure: when results: 1, departure: when
}) })
@ -140,7 +141,7 @@ test('trip details', async (t) => {
}) })
// todo: fails with `CGI_READ_FAILED` // todo: fails with `CGI_READ_FAILED`
test.skip('departures at Lausanne', async (t) => { tap.skip('departures at Lausanne', async (t) => {
const departures = await client.departures(lausanne, { const departures = await client.departures(lausanne, {
duration: 10, when, duration: 10, when,
}) })
@ -155,7 +156,7 @@ test.skip('departures at Lausanne', async (t) => {
}) })
// todo: fails with `CGI_READ_FAILED` // todo: fails with `CGI_READ_FAILED`
test.skip('departures with station object', async (t) => { tap.skip('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: '8501120', id: '8501120',
@ -172,7 +173,7 @@ test.skip('departures with station object', async (t) => {
}) })
// todo: fails with `CGI_READ_FAILED` // todo: fails with `CGI_READ_FAILED`
test.skip('arrivals at Lausanne', async (t) => { tap.skip('arrivals at Lausanne', async (t) => {
const arrivals = await client.arrivals(lausanne, { const arrivals = await client.arrivals(lausanne, {
duration: 10, when duration: 10, when
}) })
@ -188,7 +189,7 @@ test.skip('arrivals at Lausanne', async (t) => {
// todo: nearby // todo: nearby
test('locations named "ETH Hönggerberg"', async (t) => { tap.test('locations named "ETH Hönggerberg"', async (t) => {
const locations = await client.locations('ETH Hönggerberg', { const locations = await client.locations('ETH Hönggerberg', {
results: 10, results: 10,
}) })
@ -206,7 +207,7 @@ test('locations named "ETH Hönggerberg"', async (t) => {
t.end() t.end()
}) })
test('stop Lausanne', async (t) => { tap.test('stop Lausanne', async (t) => {
const s = await client.stop(lausanne) const s = await client.stop(lausanne)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -215,7 +216,7 @@ test('stop Lausanne', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 46.9984, north: 46.9984,
west: 7.3495, west: 7.3495,
@ -229,7 +230,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const sncbProfile = require('../../p/sncb') const sncbProfile = require('../../p/sncb')
const products = require('../../p/sncb/products') const products = require('../../p/sncb/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testRefreshJourney = require('./lib/refresh-journey') const testRefreshJourney = require('./lib/refresh-journey')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
@ -35,7 +36,7 @@ const gentPaddenhoek = {
latitude: 51.0517, longitude: 3.724878, latitude: 51.0517, longitude: 3.724878,
} }
test('journeys  Gent Sant Pieters to Bruxelles Midi', async (t) => { tap.test('journeys  Gent Sant Pieters to Bruxelles Midi', async (t) => {
const res = await client.journeys(gentStPieters, bruxellesMidi, { const res = await client.journeys(gentStPieters, bruxellesMidi, {
results: 4, results: 4,
departure: when, departure: when,
@ -55,7 +56,7 @@ test('journeys  Gent Sant Pieters to Bruxelles Midi', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(gentStPieters, bruxellesMidi, { const res = await client.journeys(gentStPieters, bruxellesMidi, {
results: 1, departure: when results: 1, departure: when
}) })
@ -69,20 +70,20 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('arrivals at Bruxelles Midi', async (t) => { tap.test('arrivals at Bruxelles Midi', async (t) => {
const arrivals = await client.arrivals(bruxellesMidi, { const arrivals = await client.arrivals(bruxellesMidi, {
duration: 10, when duration: 10, when
}) })
validate(t, arrivals, 'arrivals', 'arrivals') validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals') t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when)) t.same(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
// todo: nearby // todo: nearby
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 51.065, north: 51.065,
west: 3.688, west: 3.688,
@ -96,7 +97,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test.skip('reachableFrom', async (t) => { tap.skip('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const svvProfile = require('../../p/svv') const svvProfile = require('../../p/svv')
const products = require('../../p/svv/products') const products = require('../../p/svv/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testRefreshJourney = require('./lib/refresh-journey') const testRefreshJourney = require('./lib/refresh-journey')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
@ -37,7 +38,7 @@ const zillnerstr2 = {
latitude: 47.801434, longitude: 13.031006, latitude: 47.801434, longitude: 13.031006,
} }
test('journeys  Sam to Volksgarten', async (t) => { tap.test('journeys  Sam to Volksgarten', async (t) => {
const res = await client.journeys(sam, volksgarten, { const res = await client.journeys(sam, volksgarten, {
results: 4, results: 4,
departure: when, departure: when,
@ -57,7 +58,7 @@ test('journeys  Sam to Volksgarten', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(sam, volksgarten, { const res = await client.journeys(sam, volksgarten, {
results: 1, departure: when results: 1, departure: when
}) })
@ -71,20 +72,20 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('arrivals at Volksgarten', async (t) => { tap.test('arrivals at Volksgarten', async (t) => {
const arrivals = await client.arrivals(volksgarten, { const arrivals = await client.arrivals(volksgarten, {
duration: 10, when duration: 10, when
}) })
validate(t, arrivals, 'arrivals', 'arrivals') validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals') t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when)) t.same(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
// todo: nearby // todo: nearby
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,
@ -96,7 +97,7 @@ test('reachableFrom', async (t) => {
t.end() t.end()
}) })
test('serverInfo works', async (t) => { tap.test('serverInfo works', async (t) => {
await testServerInfo({ await testServerInfo({
test: t, test: t,
fetchServerInfo: client.serverInfo, fetchServerInfo: client.serverInfo,

View file

@ -1,5 +1,7 @@
'use strict' 'use strict'
const tap = require('tap')
const createClient = require('../..') const createClient = require('../..')
const vbbProfile = require('../../p/vbb') const vbbProfile = require('../../p/vbb')
const products = require('../../p/vbb/products') const products = require('../../p/vbb/products')
@ -12,7 +14,6 @@ const {
validateMovement validateMovement
} = require('./lib/vbb-bvg-validators') } = require('./lib/vbb-bvg-validators')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -45,7 +46,7 @@ const westhafen = '900000001201'
const wedding = '900000009104' const wedding = '900000009104'
const württembergallee = '900000026153' const württembergallee = '900000026153'
test('journeys  Spichernstr. to Bismarckstr.', async (t) => { tap.test('journeys  Spichernstr. to Bismarckstr.', async (t) => {
const res = await client.journeys({ const res = await client.journeys({
type: 'stop', type: 'stop',
id: spichernstr, id: spichernstr,
@ -68,7 +69,7 @@ test('journeys  Spichernstr. to Bismarckstr.', async (t) => {
t.end() t.end()
}) })
test('journeys  only subway', async (t) => { tap.test('journeys  only subway', async (t) => {
const res = await client.journeys(spichernstr, bismarckstr, { const res = await client.journeys(spichernstr, bismarckstr, {
results: 20, results: 20,
departure: when, departure: when,
@ -105,7 +106,7 @@ test('journeys  only subway', async (t) => {
// todo: journeys  with arrival time // todo: journeys  with arrival time
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -117,7 +118,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('journeys: walkingSpeed', async (t) => { tap.test('journeys: walkingSpeed', async (t) => {
const havelchaussee = { const havelchaussee = {
type: 'location', type: 'location',
address: 'Havelchaussee', address: 'Havelchaussee',
@ -138,7 +139,7 @@ test('journeys: walkingSpeed', async (t) => {
}) })
}) })
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -151,7 +152,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('refreshJourney', async (t) => { tap.test('refreshJourney', async (t) => {
await testRefreshJourney({ await testRefreshJourney({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -164,7 +165,7 @@ test('refreshJourney', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(spichernstr, amrumerStr, { const res = await client.journeys(spichernstr, amrumerStr, {
results: 1, departure: when results: 1, departure: when
}) })
@ -178,7 +179,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('journeys  station to address', async (t) => { tap.test('journeys  station to address', async (t) => {
const torfstr = { const torfstr = {
type: 'location', type: 'location',
address: '13353 Berlin-Wedding, Torfstr. 17', address: '13353 Berlin-Wedding, Torfstr. 17',
@ -200,7 +201,7 @@ test('journeys  station to address', async (t) => {
t.end() t.end()
}) })
test('journeys  station to POI', async (t) => { tap.test('journeys  station to POI', async (t) => {
const atze = { const atze = {
type: 'location', type: 'location',
id: '900980720', id: '900980720',
@ -224,7 +225,7 @@ test('journeys  station to POI', async (t) => {
t.end() t.end()
}) })
test('journeys: via works with detour', async (t) => { tap.test('journeys: via works with detour', async (t) => {
// Going from Westhafen to Wedding via Württembergalle without detour // Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine computes a detour. // is currently impossible. We check if the routing engine computes a detour.
const res = await client.journeys(westhafen, wedding, { const res = await client.journeys(westhafen, wedding, {
@ -245,7 +246,7 @@ test('journeys: via works with detour', async (t) => {
// todo: without detour test // todo: without detour test
test('departures', async (t) => { tap.test('departures', async (t) => {
const departures = await client.departures(spichernstr, { const departures = await client.departures(spichernstr, {
duration: 5, when, duration: 5, when,
}) })
@ -259,7 +260,7 @@ test('departures', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: spichernstr, id: spichernstr,
@ -275,7 +276,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('departures at Spichernstr. in direction of Westhafen', async (t) => { tap.test('departures at Spichernstr. in direction of Westhafen', async (t) => {
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
fetchDepartures: client.departures, fetchDepartures: client.departures,
@ -288,14 +289,14 @@ test('departures at Spichernstr. in direction of Westhafen', async (t) => {
t.end() t.end()
}) })
test('departures at 7-digit station', async (t) => { tap.test('departures at 7-digit station', async (t) => {
const eisenach = '8010097' // see derhuerst/vbb-hafas#22 const eisenach = '8010097' // see derhuerst/vbb-hafas#22
await client.departures(eisenach, {when}) await client.departures(eisenach, {when})
t.pass('did not fail') t.pass('did not fail')
t.end() t.end()
}) })
test('arrivals', async (t) => { tap.test('arrivals', async (t) => {
const arrivals = await client.arrivals(spichernstr, { const arrivals = await client.arrivals(spichernstr, {
duration: 5, when, duration: 5, when,
}) })
@ -309,7 +310,7 @@ test('arrivals', async (t) => {
t.end() t.end()
}) })
test('nearby', async (t) => { tap.test('nearby', async (t) => {
const berlinerStr = '900000044201' const berlinerStr = '900000044201'
const landhausstr = '900000043252' const landhausstr = '900000043252'
@ -335,7 +336,7 @@ test('nearby', async (t) => {
t.end() t.end()
}) })
test('locations', async (t) => { tap.test('locations', async (t) => {
const locations = await client.locations('Alexanderplatz', {results: 20}) const locations = await client.locations('Alexanderplatz', {results: 20})
validate(t, locations, 'locations', 'locations') validate(t, locations, 'locations', 'locations')
@ -348,7 +349,7 @@ test('locations', async (t) => {
t.end() t.end()
}) })
test('stop', async (t) => { tap.test('stop', async (t) => {
const s = await client.stop(spichernstr) const s = await client.stop(spichernstr)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -357,7 +358,7 @@ test('stop', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 52.52411, north: 52.52411,
west: 13.41002, west: 13.41002,
@ -371,7 +372,7 @@ test('radar', async (t) => {
t.end() t.end()
}) })
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
const torfstr17 = { const torfstr17 = {
type: 'location', type: 'location',
address: '13353 Berlin-Wedding, Torfstr. 17', address: '13353 Berlin-Wedding, Torfstr. 17',

View file

@ -1,11 +1,12 @@
'use strict' 'use strict'
const tap = require('tap')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
const createClient = require('../..') const createClient = require('../..')
const vbnProfile = require('../../p/vbn') const vbnProfile = require('../../p/vbn')
const products = require('../../p/vbn/products') const products = require('../../p/vbn/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testArrivals = require('./lib/arrivals') const testArrivals = require('./lib/arrivals')
const testReachableFrom = require('./lib/reachable-from') const testReachableFrom = require('./lib/reachable-from')
@ -29,7 +30,7 @@ const client = createClient(vbnProfile, 'public-transport/hafas-client:test')
const oldenburg = '8000291' const oldenburg = '8000291'
const bremenHumboldtstr = '9013973' const bremenHumboldtstr = '9013973'
test('journeys  Oldenburg to Bremen Humboldtstr.', async (t) => { tap.test('journeys  Oldenburg to Bremen Humboldtstr.', async (t) => {
const res = await client.journeys(oldenburg, bremenHumboldtstr, { const res = await client.journeys(oldenburg, bremenHumboldtstr, {
results: 4, results: 4,
departure: when, departure: when,
@ -49,7 +50,7 @@ test('journeys  Oldenburg to Bremen Humboldtstr.', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: without detour // todo: without detour
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(oldenburg, bremenHumboldtstr, { const res = await client.journeys(oldenburg, bremenHumboldtstr, {
results: 1, departure: when results: 1, departure: when
}) })
@ -63,20 +64,20 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('arrivals at Bremen Humboldtstr.', async (t) => { tap.test('arrivals at Bremen Humboldtstr.', async (t) => {
const arrivals = await client.arrivals(bremenHumboldtstr, { const arrivals = await client.arrivals(bremenHumboldtstr, {
duration: 10, when duration: 10, when
}) })
validate(t, arrivals, 'arrivals', 'arrivals') validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals') t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when)) t.same(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end() t.end()
}) })
// todo: nearby // todo: nearby
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 53.090516, north: 53.090516,
west: 8.750106, west: 8.750106,
@ -91,7 +92,7 @@ test('radar', async (t) => {
}) })
// todo: fails with "HCI Service: location missing or invalid" // todo: fails with "HCI Service: location missing or invalid"
test('reachableFrom', async (t) => { tap.test('reachableFrom', async (t) => {
await testReachableFrom({ await testReachableFrom({
test: t, test: t,
reachableFrom: client.reachableFrom, reachableFrom: client.reachableFrom,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const vrnProfile = require('../../p/vrn') const vrnProfile = require('../../p/vrn')
const products = require('../../p/vrn/products') const products = require('../../p/vrn/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product') const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
@ -36,7 +36,7 @@ const client = createClient(vrnProfile, 'public-transport/hafas-client:test')
const ludwigshafen = '8000236' const ludwigshafen = '8000236'
const meckesheim = '8003932' const meckesheim = '8003932'
test('journeys  Ludwigshafen to Meckesheim', async (t) => { tap.test('journeys  Ludwigshafen to Meckesheim', async (t) => {
const res = await client.journeys(ludwigshafen, meckesheim, { const res = await client.journeys(ludwigshafen, meckesheim, {
results: 4, results: 4,
departure: when, departure: when,
@ -55,7 +55,7 @@ test('journeys  Ludwigshafen to Meckesheim', async (t) => {
// todo: journeys, only one product // todo: journeys, only one product
test('journeys  fails with no product', (t) => { tap.test('journeys  fails with no product', (t) => {
journeysFailsWithNoProduct({ journeysFailsWithNoProduct({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -67,7 +67,7 @@ test('journeys  fails with no product', (t) => {
t.end() t.end()
}) })
test('Ludwigshafen to Pestalozzistr. 2, Ludwigshafen', async (t) => { tap.test('Ludwigshafen to Pestalozzistr. 2, Ludwigshafen', async (t) => {
const pestalozzistr2 = { const pestalozzistr2 = {
type: 'location', type: 'location',
id: '980787337', id: '980787337',
@ -90,7 +90,7 @@ test('Ludwigshafen to Pestalozzistr. 2, Ludwigshafen', async (t) => {
t.end() t.end()
}) })
test('Ludwigshafen to Südwest-Stadion', async (t) => { tap.test('Ludwigshafen to Südwest-Stadion', async (t) => {
const südweststadion = { const südweststadion = {
type: 'location', type: 'location',
id: '991664983', id: '991664983',
@ -116,7 +116,7 @@ test('Ludwigshafen to Südwest-Stadion', async (t) => {
// todo: via works with detour // todo: via works with detour
// todo: via works without detour // todo: via works without detour
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -129,7 +129,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(ludwigshafen, meckesheim, { const res = await client.journeys(ludwigshafen, meckesheim, {
results: 1, departure: when results: 1, departure: when
}) })
@ -143,7 +143,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test('departures at Meckesheim', async (t) => { tap.test('departures at Meckesheim', async (t) => {
const departures = await client.departures(meckesheim, { const departures = await client.departures(meckesheim, {
duration: 3 * 60, when, duration: 3 * 60, when,
}) })
@ -157,7 +157,7 @@ test('departures at Meckesheim', async (t) => {
t.end() t.end()
}) })
test('departures at Meckesheim in direction of Reilsheim', async (t) => { tap.test('departures at Meckesheim in direction of Reilsheim', async (t) => {
const reilsheim = '8005015' const reilsheim = '8005015'
await testDeparturesInDirection({ await testDeparturesInDirection({
test: t, test: t,
@ -171,7 +171,7 @@ test('departures at Meckesheim in direction of Reilsheim', async (t) => {
t.end() t.end()
}) })
test('arrivals at Meckesheim', async (t) => { tap.test('arrivals at Meckesheim', async (t) => {
const arrivals = await client.arrivals(meckesheim, { const arrivals = await client.arrivals(meckesheim, {
duration: 3 * 60, when duration: 3 * 60, when
}) })
@ -187,7 +187,7 @@ test('arrivals at Meckesheim', async (t) => {
// todo: nearby // todo: nearby
test('locations named Ebertpark', async (t) => { tap.test('locations named Ebertpark', async (t) => {
const ebertpark = '506453' const ebertpark = '506453'
const locations = await client.locations('Ebertpark', { const locations = await client.locations('Ebertpark', {
results: 20 results: 20
@ -205,7 +205,7 @@ test('locations named Ebertpark', async (t) => {
t.end() t.end()
}) })
test('station Meckesheim', async (t) => { tap.test('station Meckesheim', async (t) => {
const s = await client.stop(meckesheim) const s = await client.stop(meckesheim)
validate(t, s, ['stop', 'station'], 'station') validate(t, s, ['stop', 'station'], 'station')
@ -214,7 +214,7 @@ test('station Meckesheim', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 49.4940, north: 49.4940,
west: 8.4560, west: 8.4560,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const vsnProfile = require('../../p/vsn') const vsnProfile = require('../../p/vsn')
const products = require('../../p/vsn/products') const products = require('../../p/vsn/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
@ -34,7 +34,7 @@ const kornmarkt = '9033977'
const jugendherberge = '9033961' const jugendherberge = '9033961'
const ewaldstrasse = '9033896' const ewaldstrasse = '9033896'
test('journeys  Kornmarkt to Ewaldstraße', async (t) => { tap.test('journeys  Kornmarkt to Ewaldstraße', async (t) => {
const res = await client.journeys(kornmarkt, ewaldstrasse, { const res = await client.journeys(kornmarkt, ewaldstrasse, {
results: 4, results: 4,
departure: when, departure: when,
@ -51,7 +51,7 @@ test('journeys  Kornmarkt to Ewaldstraße', async (t) => {
t.end() t.end()
}) })
test('Ewaldstraße to 37083 Göttingen, Schulweg 22', async (t) => { tap.test('Ewaldstraße to 37083 Göttingen, Schulweg 22', async (t) => {
const schulweg = { const schulweg = {
type: 'location', type: 'location',
address: '37083 Göttingen, Schulweg 22', address: '37083 Göttingen, Schulweg 22',
@ -72,7 +72,7 @@ test('Ewaldstraße to 37083 Göttingen, Schulweg 22', async (t) => {
t.end() t.end()
}) })
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -85,7 +85,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip', async (t) => { tap.test('trip', async (t) => {
const { journeys } = await client.journeys(jugendherberge, kornmarkt, { const { journeys } = await client.journeys(jugendherberge, kornmarkt, {
results: 1, departure: when results: 1, departure: when
}) })
@ -99,7 +99,7 @@ test('trip', async (t) => {
t.end() t.end()
}) })
test('departures at Kornmarkt.', async (t) => { tap.test('departures at Kornmarkt.', async (t) => {
const departures = await client.departures(kornmarkt, { const departures = await client.departures(kornmarkt, {
duration: 20, when duration: 20, when
}) })
@ -113,7 +113,7 @@ test('departures at Kornmarkt.', async (t) => {
t.end() t.end()
}) })
test('arrivals at Kornmarkt.', async (t) => { tap.test('arrivals at Kornmarkt.', async (t) => {
const arrivals = await client.arrivals(kornmarkt, { const arrivals = await client.arrivals(kornmarkt, {
duration: 20, when duration: 20, when
}) })
@ -127,7 +127,7 @@ test('arrivals at Kornmarkt.', async (t) => {
t.end() t.end()
}) })
test('departures with station object', async (t) => { tap.test('departures with station object', async (t) => {
const deps = await client.departures({ const deps = await client.departures({
type: 'station', type: 'station',
id: kornmarkt, id: kornmarkt,
@ -143,7 +143,7 @@ test('departures with station object', async (t) => {
t.end() t.end()
}) })
test('locations named Botanischer Garten', async (t) => { tap.test('locations named Botanischer Garten', async (t) => {
const locations = await client.locations('Botanischer Garten', { const locations = await client.locations('Botanischer Garten', {
results: 20 results: 20
}) })
@ -157,7 +157,7 @@ test('locations named Botanischer Garten', async (t) => {
t.end() t.end()
}) })
test('stop Jugendherberge', async (t) => { tap.test('stop Jugendherberge', async (t) => {
const s = await client.stop(jugendherberge) const s = await client.stop(jugendherberge)
validate(t, s, ['stop', 'station'], 'stop') validate(t, s, ['stop', 'station'], 'stop')
@ -166,7 +166,7 @@ test('stop Jugendherberge', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 52, north: 52,
west: 9.8, west: 9.8,

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
const tap = require('tap')
const isRoughlyEqual = require('is-roughly-equal') const isRoughlyEqual = require('is-roughly-equal')
const {createWhen} = require('./lib/util') const {createWhen} = require('./lib/util')
@ -7,7 +8,6 @@ const createClient = require('../..')
const zvvProfile = require('../../p/zvv') const zvvProfile = require('../../p/zvv')
const products = require('../../p/zvv/products') const products = require('../../p/zvv/products')
const createValidate = require('./lib/validate-fptf-with') const createValidate = require('./lib/validate-fptf-with')
const {test} = require('./lib/util')
const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product') const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
@ -33,7 +33,7 @@ const client = createClient(zvvProfile, 'public-transport/hafas-client:test')
const bürkliplatz = '8591105' const bürkliplatz = '8591105'
const ethUniversitätsspital = '8591123' const ethUniversitätsspital = '8591123'
test('journeys  Bürkliplatz to ETH/Universitätsspital', async (t) => { tap.test('journeys  Bürkliplatz to ETH/Universitätsspital', async (t) => {
const res = await client.journeys(bürkliplatz, ethUniversitätsspital, { const res = await client.journeys(bürkliplatz, ethUniversitätsspital, {
results: 4, results: 4,
departure: when, departure: when,
@ -50,7 +50,7 @@ test('journeys  Bürkliplatz to ETH/Universitätsspital', async (t) => {
t.end() t.end()
}) })
test('earlier/later journeys', async (t) => { tap.test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({ await testEarlierLaterJourneys({
test: t, test: t,
fetchJourneys: client.journeys, fetchJourneys: client.journeys,
@ -63,7 +63,7 @@ test('earlier/later journeys', async (t) => {
t.end() t.end()
}) })
test('trip details', async (t) => { tap.test('trip details', async (t) => {
const res = await client.journeys(bürkliplatz, ethUniversitätsspital, { const res = await client.journeys(bürkliplatz, ethUniversitätsspital, {
results: 1, departure: when results: 1, departure: when
}) })
@ -77,7 +77,7 @@ test('trip details', async (t) => {
t.end() t.end()
}) })
test.skip('departures at ETH/Universitätsspital', async (t) => { // todo tap.skip('departures at ETH/Universitätsspital', async (t) => { // todo
const departures = await client.departures(ethUniversitätsspital, { const departures = await client.departures(ethUniversitätsspital, {
duration: 5, when, duration: 5, when,
}) })
@ -94,7 +94,7 @@ test.skip('departures at ETH/Universitätsspital', async (t) => { // todo
// todo: departures in direction // todo: departures in direction
// todo: nearby // todo: nearby
test('locations named Rennweg', async (t) => { tap.test('locations named Rennweg', async (t) => {
const rennweg = '8591316' const rennweg = '8591316'
const locations = await client.locations('Rennweg', { const locations = await client.locations('Rennweg', {
results: 20, results: 20,
@ -111,7 +111,7 @@ test('locations named Rennweg', async (t) => {
t.end() t.end()
}) })
test('radar', async (t) => { tap.test('radar', async (t) => {
const vehicles = await client.radar({ const vehicles = await client.radar({
north: 47.387, north: 47.387,
west: 8.514, west: 8.514,

View file

@ -1,5 +0,0 @@
'use strict'
Error.stackTraceLimit = Infinity
require('./products-filter')

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const format = require('../../format/products-filter') const format = require('../../format/products-filter')
const products = [ const products = [
@ -27,10 +27,10 @@ const ctx = {
profile: {products} profile: {products}
} }
test('formatProductsFilter works without customisations', (t) => { tap.test('formatProductsFilter works without customisations', (t) => {
const expected = 1 | 2 | 4 const expected = 1 | 2 | 4
const filter = {} const filter = {}
t.deepEqual(format(ctx, filter), { t.same(format(ctx, filter), {
type: 'PROD', type: 'PROD',
mode: 'INC', mode: 'INC',
value: expected + '' value: expected + ''
@ -38,7 +38,7 @@ test('formatProductsFilter works without customisations', (t) => {
t.end() t.end()
}) })
test('formatProductsFilter works with customisations', (t) => { tap.test('formatProductsFilter works with customisations', (t) => {
t.equal(+format(ctx, { t.equal(+format(ctx, {
bus: true bus: true
}).value, 1 | 2 | 4) }).value, 1 | 2 | 4)

View file

@ -1,28 +0,0 @@
'use strict'
Error.stackTraceLimit = Infinity
require('./parse')
require('./format')
require('./db-stop')
require('./sbb-journeys')
require('./insa-stop')
require('./bvg-journey')
require('./db-journey')
require('./db-journey-2')
require('./db-journey-polyline')
require('./db-arrivals')
require('./vbb-departures')
require('./vbb-journeys')
require('./bvg-radar')
require('./oebb-trip')
require('./rejseplanen-trip')
require('./vsn-remarks')
require('./db-netz-remarks')
require('./vsn-departures')
require('./mobiliteit-lu-line')
require('./rsag-journey')
require('./throttle')
require('./retry')

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/insa') const rawProfile = require('../p/insa')
@ -15,11 +15,11 @@ const opt = {
remarks: true, remarks: true,
} }
test('parses a stop() response correctly (INSA)', (t) => { tap.test('parses a stop() response correctly (INSA)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const stop = profile.parseLocation(ctx, res.locL[0]) const stop = profile.parseLocation(ctx, res.locL[0])
t.deepEqual(stop, expected) t.same(stop, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/mobiliteit-lu') const rawProfile = require('../p/mobiliteit-lu')
@ -13,7 +13,7 @@ const opt = {
remarks: true, remarks: true,
} }
test('parses a line correctly (mobiliteit.lu)', (t) => { tap.test('parses a line correctly (mobiliteit.lu)', (t) => {
const rawLine = { const rawLine = {
pid: 'L::1::IC::B1303038328::IC_1303038328::*', pid: 'L::1::IC::B1303038328::IC_1303038328::*',
name: 'IC 108', name: 'IC 108',
@ -37,7 +37,7 @@ test('parses a line correctly (mobiliteit.lu)', (t) => {
const ctx = {profile, opt} const ctx = {profile, opt}
const stop = profile.parseLine(ctx, rawLine) const stop = profile.parseLine(ctx, rawLine)
t.deepEqual(stop, { t.same(stop, {
type: 'line', type: 'line',
id: 'ic-108', id: 'ic-108',
fahrtNr: '108', fahrtNr: '108',

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/oebb') const rawProfile = require('../p/oebb')
@ -19,11 +19,11 @@ const opt = {
when: '2020-06-11T15:25:00+02:00', when: '2020-06-11T15:25:00+02:00',
} }
test('parses a trip correctly (ÖBB)', (t) => { tap.test('parses a trip correctly (ÖBB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const trip = profile.parseTrip(ctx, res.journey) const trip = profile.parseTrip(ctx, res.journey)
t.deepEqual(trip, expected) t.same(trip, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/date-time') const parse = require('../../parse/date-time')
const ctx = { const ctx = {
@ -12,7 +12,7 @@ const ctx = {
} }
} }
test('date & time parsing returns a timestamp', (t) => { tap.test('date & time parsing returns a timestamp', (t) => {
const iso = parse(ctx, '20190819', '203000', undefined, false) const iso = parse(ctx, '20190819', '203000', undefined, false)
const ts = parse(ctx, '20190819', '203000', undefined, true) const ts = parse(ctx, '20190819', '203000', undefined, true)
t.equal(ts, +new Date(iso)) t.equal(ts, +new Date(iso))
@ -20,32 +20,32 @@ test('date & time parsing returns a timestamp', (t) => {
t.end() t.end()
}) })
test('date & time parsing uses tzOffset', (t) => { tap.test('date & time parsing uses tzOffset', (t) => {
const iso = parse(ctx, '20190819', '203000', -120, false) const iso = parse(ctx, '20190819', '203000', -120, false)
t.equal(iso, '2019-08-19T20:30:00-02:00') t.equal(iso, '2019-08-19T20:30:00-02:00')
t.end() t.end()
}) })
test('date & time parsing works with day "overflow"', (t) => { tap.test('date & time parsing works with day "overflow"', (t) => {
const iso = parse(ctx, '20190819', '02203000', undefined, false) const iso = parse(ctx, '20190819', '02203000', undefined, false)
t.equal(iso, '2019-08-21T20:30:00+02:00') t.equal(iso, '2019-08-21T20:30:00+02:00')
t.end() t.end()
}) })
// #106 // #106
test('date & time parsing works with day "overflow" & tzOffset', (t) => { tap.test('date & time parsing works with day "overflow" & tzOffset', (t) => {
const iso = parse(ctx, '20190819', '02203000', -120, false) const iso = parse(ctx, '20190819', '02203000', -120, false)
t.equal(iso, '2019-08-21T20:30:00-02:00') t.equal(iso, '2019-08-21T20:30:00-02:00')
t.end() t.end()
}) })
test('date & time parsing works with summer & winter time', (t) => { tap.test('date & time parsing works with summer & winter time', (t) => {
const iso = parse(ctx, '20190219', '203000', undefined, false) const iso = parse(ctx, '20190219', '203000', undefined, false)
t.equal(iso, '2019-02-19T20:30:00+01:00') t.equal(iso, '2019-02-19T20:30:00+01:00')
t.end() t.end()
}) })
test('date & time parsing uses profile.timezone', (t) => { tap.test('date & time parsing uses profile.timezone', (t) => {
const iso = parse({ const iso = parse({
...ctx, ...ctx,
profile: {...ctx.profile, timezone: 'Europe/Moscow'} profile: {...ctx.profile, timezone: 'Europe/Moscow'}

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/hint') const parse = require('../../parse/hint')
const ctx = { const ctx = {
@ -9,7 +9,7 @@ const ctx = {
profile: {} profile: {}
} }
test('parses hints correctly', (t) => { tap.test('parses hints correctly', (t) => {
const input = { const input = {
type: 'A', type: 'A',
code: 'bf', code: 'bf',
@ -22,20 +22,20 @@ test('parses hints correctly', (t) => {
text: 'some text' text: 'some text'
} }
t.deepEqual(parse(ctx, input), expected) t.same(parse(ctx, input), expected)
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, type: 'I' ...input, type: 'I'
}), expected) }), expected)
// alternative trip // alternative trip
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, type: 'L', jid: 'trip id' ...input, type: 'L', jid: 'trip id'
}), { }), {
...expected, type: 'status', code: 'alternative-trip', tripId: 'trip id' ...expected, type: 'status', code: 'alternative-trip', tripId: 'trip id'
}) })
// type: M // type: M
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, type: 'M', txtS: 'some summary' ...input, type: 'M', txtS: 'some summary'
}), { }), {
...expected, type: 'status', summary: 'some summary' ...expected, type: 'status', summary: 'some summary'
@ -43,13 +43,13 @@ test('parses hints correctly', (t) => {
// type: D // type: D
for (const type of ['D', 'U', 'R', 'N', 'Y']) { for (const type of ['D', 'U', 'R', 'N', 'Y']) {
t.deepEqual(parse(ctx, {...input, type}), { t.same(parse(ctx, {...input, type}), {
...expected, type: 'status' ...expected, type: 'status'
}) })
} }
// .code via .icon // .code via .icon
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, code: null, icon: {type: 'cancel'} ...input, code: null, icon: {type: 'cancel'}
}), {...expected, code: 'cancelled'}) }), {...expected, code: 'cancelled'})

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/icon') const parse = require('../../parse/icon')
const ctx = { const ctx = {
@ -9,12 +9,12 @@ const ctx = {
profile: {} profile: {}
} }
test('parses icons correctly', (t) => { tap.test('parses icons correctly', (t) => {
const text = { const text = {
"res": "BVG", "res": "BVG",
"text": "Berliner Verkehrsbetriebe" "text": "Berliner Verkehrsbetriebe"
} }
t.deepEqual(parse(ctx, text), { t.same(parse(ctx, text), {
type: 'BVG', type: 'BVG',
title: 'Berliner Verkehrsbetriebe' title: 'Berliner Verkehrsbetriebe'
}) })
@ -23,7 +23,7 @@ test('parses icons correctly', (t) => {
"res": "PROD_BUS", "res": "PROD_BUS",
"txtS": "18" "txtS": "18"
} }
t.deepEqual(parse(ctx, txtS), { t.same(parse(ctx, txtS), {
type: 'PROD_BUS', type: 'PROD_BUS',
title: '18' title: '18'
}) })
@ -32,7 +32,7 @@ test('parses icons correctly', (t) => {
"res": "RBB", "res": "RBB",
"txt": "Regionalbus Braunschweig GmbH" "txt": "Regionalbus Braunschweig GmbH"
} }
t.deepEqual(parse(ctx, txt), { t.same(parse(ctx, txt), {
type: 'RBB', type: 'RBB',
title: 'Regionalbus Braunschweig GmbH' title: 'Regionalbus Braunschweig GmbH'
}) })
@ -40,7 +40,7 @@ test('parses icons correctly', (t) => {
const noText = { const noText = {
"res": "attr_bike_r" "res": "attr_bike_r"
} }
t.deepEqual(parse(ctx, noText), { t.same(parse(ctx, noText), {
type: 'attr_bike_r', type: 'attr_bike_r',
title: null title: null
}) })
@ -60,7 +60,7 @@ test('parses icons correctly', (t) => {
"a": 255 "a": 255
} }
} }
t.deepEqual(parse(ctx, withColor), { t.same(parse(ctx, withColor), {
type: 'prod_sub_t', type: 'prod_sub_t',
title: null, title: null,
fgColor: {r: 255, g: 255, b: 255, a: 255}, fgColor: {r: 255, g: 255, b: 255, a: 255},

View file

@ -1,12 +0,0 @@
'use strict'
Error.stackTraceLimit = Infinity
require('./date-time')
require('./icon')
require('./operator')
require('./location')
require('./when')
require('./line')
require('./hint')
require('./warning')

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/line') const parse = require('../../parse/line')
const profile = { const profile = {
@ -16,7 +16,7 @@ const ctx = {
profile profile
} }
test('parses lines correctly', (t) => { tap.test('parses lines correctly', (t) => {
const input = { const input = {
line: 'foo line', line: 'foo line',
prodCtx: { prodCtx: {
@ -32,23 +32,23 @@ test('parses lines correctly', (t) => {
public: true public: true
} }
t.deepEqual(parse(ctx, input), expected) t.same(parse(ctx, input), expected)
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, line: null, addName: input.line ...input, line: null, addName: input.line
}), expected) }), expected)
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, line: null, name: input.line ...input, line: null, name: input.line
}), expected) }), expected)
// no prodCtx.lineId // no prodCtx.lineId
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, prodCtx: {...input.prodCtx, lineId: null} ...input, prodCtx: {...input.prodCtx, lineId: null}
}), { }), {
...expected, id: 'foo-line' ...expected, id: 'foo-line'
}) })
// no prodCtx // no prodCtx
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, prodCtx: undefined ...input, prodCtx: undefined
}), { }), {
...expected, id: 'foo-line', fahrtNr: null ...expected, id: 'foo-line', fahrtNr: null

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const omit = require('lodash/omit') const omit = require('lodash/omit')
const parse = require('../../parse/location') const parse = require('../../parse/location')
@ -20,7 +20,7 @@ const ctx = {
profile profile
} }
test('parses an address correctly', (t) => { tap.test('parses an address correctly', (t) => {
const input = { const input = {
type: 'A', type: 'A',
name: 'Foo street 3', name: 'Foo street 3',
@ -29,7 +29,7 @@ test('parses an address correctly', (t) => {
} }
const address = parse(ctx, input) const address = parse(ctx, input)
t.deepEqual(address, { t.same(address, {
type: 'location', type: 'location',
id: 'some id', id: 'some id',
address: 'Foo street 3', address: 'Foo street 3',
@ -40,7 +40,7 @@ test('parses an address correctly', (t) => {
t.end() t.end()
}) })
test('parses a POI correctly', (t) => { tap.test('parses a POI correctly', (t) => {
const input = { const input = {
type: 'P', type: 'P',
name: 'some POI', name: 'some POI',
@ -49,7 +49,7 @@ test('parses a POI correctly', (t) => {
} }
const poi = parse(ctx, input) const poi = parse(ctx, input)
t.deepEqual(poi, { t.same(poi, {
type: 'location', type: 'location',
poi: true, poi: true,
id: 'some id', id: 'some id',
@ -75,9 +75,9 @@ const fooBusStop = {
pCls: 123 pCls: 123
} }
test('parses a stop correctly', (t) => { tap.test('parses a stop correctly', (t) => {
const stop = parse(ctx, fooBusStop) const stop = parse(ctx, fooBusStop)
t.deepEqual(stop, { t.same(stop, {
type: 'stop', type: 'stop',
id: 'foo stop', id: 'foo stop',
name: 'foo bus stop', // lower-cased! name: 'foo bus stop', // lower-cased!
@ -106,12 +106,12 @@ test('parses a stop correctly', (t) => {
}, { }, {
...fooBusStop, lines: [lineA] ...fooBusStop, lines: [lineA]
}) })
t.deepEqual(withLines.lines, [lineA]) t.same(withLines.lines, [lineA])
t.end() t.end()
}) })
test('falls back to coordinates from `lid`', (t) => { tap.test('falls back to coordinates from `lid`', (t) => {
const {location} = parse(ctx, { const {location} = parse(ctx, {
type: 'S', type: 'S',
name: 'foo', name: 'foo',
@ -123,7 +123,7 @@ test('falls back to coordinates from `lid`', (t) => {
t.end() t.end()
}) })
test('handles recursive references properly', (t) => { tap.test('handles recursive references properly', (t) => {
const southernInput = { const southernInput = {
type: 'S', type: 'S',
name: 'Southern Platform', name: 'Southern Platform',
@ -171,14 +171,14 @@ test('handles recursive references properly', (t) => {
...fooBusStop, ...fooBusStop,
entryLocL: [0] entryLocL: [0]
}) })
t.deepEqual(entrances, [southernExpected.location]) t.same(entrances, [southernExpected.location])
const {type, stops} = parse(_ctx, { const {type, stops} = parse(_ctx, {
...fooBusStop, ...fooBusStop,
stopLocL: [0] stopLocL: [0]
}) })
t.equal(type, 'station') t.equal(type, 'station')
t.deepEqual(stops, [southernExpected]) t.same(stops, [southernExpected])
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/operator') const parse = require('../../parse/operator')
const ctx = { const ctx = {
@ -8,14 +8,14 @@ const ctx = {
opt: {}, opt: {},
profile: {} profile: {}
} }
test('parses an operator correctly', (t) => { tap.test('parses an operator correctly', (t) => {
const op = { const op = {
"name": "Berliner Verkehrsbetriebe", "name": "Berliner Verkehrsbetriebe",
"icoX": 1, "icoX": 1,
"id": "Berliner Verkehrsbetriebe" "id": "Berliner Verkehrsbetriebe"
} }
t.deepEqual(parse(ctx, op), { t.same(parse(ctx, op), {
type: 'operator', type: 'operator',
id: 'berliner-verkehrsbetriebe', id: 'berliner-verkehrsbetriebe',
name: 'Berliner Verkehrsbetriebe' name: 'Berliner Verkehrsbetriebe'

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/warning') const parse = require('../../parse/warning')
const profile = { const profile = {
@ -13,7 +13,7 @@ const ctx = {
profile profile
} }
test('parses warnings correctly', (t) => { tap.test('parses warnings correctly', (t) => {
const input = { const input = {
hid: 'some warning ID', // todo: null hid: 'some warning ID', // todo: null
head: 'some<br>summary', // todo: null head: 'some<br>summary', // todo: null
@ -32,26 +32,26 @@ test('parses warnings correctly', (t) => {
category: 1 category: 1
} }
t.deepEqual(parse(ctx, input), expected) t.same(parse(ctx, input), expected)
// without basic fields // without basic fields
t.deepEqual(parse(ctx, {...input, hid: null}), {...expected, id: null}) t.same(parse(ctx, {...input, hid: null}), {...expected, id: null})
t.deepEqual(parse(ctx, {...input, head: null}), {...expected, summary: null}) t.same(parse(ctx, {...input, head: null}), {...expected, summary: null})
t.deepEqual(parse(ctx, {...input, text: null}), {...expected, text: null}) t.same(parse(ctx, {...input, text: null}), {...expected, text: null})
t.deepEqual(parse(ctx, {...input, cat: null}), {...expected, category: null}) t.same(parse(ctx, {...input, cat: null}), {...expected, category: null})
// without icon // without icon
t.deepEqual(parse(ctx, {...input, icon: null}), { t.same(parse(ctx, {...input, icon: null}), {
...expected, type: 'warning', icon: null ...expected, type: 'warning', icon: null
}) })
// with products // with products
t.deepEqual(parse(ctx, {...input, prod: 123}), { t.same(parse(ctx, {...input, prod: 123}), {
...expected, products: [123] ...expected, products: [123]
}) })
// validFrom, validUntil, modified // validFrom, validUntil, modified
t.deepEqual(parse(ctx, { t.same(parse(ctx, {
...input, ...input,
sDate: '20190101', sTime: '094020', sDate: '20190101', sTime: '094020',
eDate: '20190101', eTime: '114020', eDate: '20190101', eTime: '114020',

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const parse = require('../../parse/when') const parse = require('../../parse/when')
const profile = { const profile = {
@ -15,7 +15,7 @@ const ctx = {
profile profile
} }
test('parseWhen works correctly', (t) => { tap.test('parseWhen works correctly', (t) => {
const date = '20190606' const date = '20190606'
const timeS = '163000' const timeS = '163000'
const timeR = '163130' const timeR = '163130'
@ -26,15 +26,15 @@ test('parseWhen works correctly', (t) => {
delay: 130 // seconds delay: 130 // seconds
} }
t.deepEqual(parse(ctx, date, timeS, timeR, tzOffset), expected) t.same(parse(ctx, date, timeS, timeR, tzOffset), expected)
// no realtime data // no realtime data
t.deepEqual(parse(ctx, date, timeS, null, tzOffset), { t.same(parse(ctx, date, timeS, null, tzOffset), {
...expected, when: expected.plannedWhen, delay: null ...expected, when: expected.plannedWhen, delay: null
}) })
// cancelled // cancelled
t.deepEqual(parse(ctx, date, timeS, timeR, tzOffset, true), { t.same(parse(ctx, date, timeS, timeR, tzOffset, true), {
...expected, ...expected,
when: null, when: null,
prognosedWhen: expected.when prognosedWhen: expected.when

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/rejseplanen') const rawProfile = require('../p/rejseplanen')
@ -19,11 +19,11 @@ const opt = {
when: '2020-07-11T16:49:00+02:00', when: '2020-07-11T16:49:00+02:00',
} }
test('parses a trip correctly (Rejseplanen)', (t) => { tap.test('parses a trip correctly (Rejseplanen)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const trip = profile.parseTrip(ctx, res.journey) const trip = profile.parseTrip(ctx, res.journey)
t.deepEqual(trip, expected) t.same(trip, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const withRetrying = require('../retry') const withRetrying = require('../retry')
@ -9,7 +9,7 @@ const vbbProfile = require('../p/vbb')
const userAgent = 'public-transport/hafas-client:test' const userAgent = 'public-transport/hafas-client:test'
const spichernstr = '900000042101' const spichernstr = '900000042101'
test('withRetrying works', (t) => { tap.test('withRetrying works', (t) => {
// for the first 3 calls, return different kinds of errors // for the first 3 calls, return different kinds of errors
let calls = 0 let calls = 0
const failingRequest = async (ctx, userAgent, reqData) => { const failingRequest = async (ctx, userAgent, reqData) => {
@ -44,7 +44,7 @@ test('withRetrying works', (t) => {
t.plan(1 + 4) t.plan(1 + 4)
client.departures(spichernstr, {duration: 1}) client.departures(spichernstr, {duration: 1})
.then(deps => t.deepEqual(deps, [], 'resolved with invalid value')) .then(deps => t.same(deps, [], 'resolved with invalid value'))
.catch(t.ifError) .catch(t.ifError)
setTimeout(() => t.equal(calls, 1), 50) // buffer setTimeout(() => t.equal(calls, 1), 50) // buffer

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/rsag') const rawProfile = require('../p/rsag')
@ -20,11 +20,11 @@ const opt = {
products: {} products: {}
} }
test('parses a journey correctly (RSAG)', (t) => { tap.test('parses a journey correctly (RSAG)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journey = profile.parseJourney(ctx, res.outConL[0]) const journey = profile.parseJourney(ctx, res.outConL[0])
t.deepEqual(journey, expected) t.same(journey, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/sbb') const rawProfile = require('../p/sbb')
@ -30,11 +30,11 @@ const opt = {
products: {}, products: {},
} }
test('parses a journeys() response correctly (SBB)', (t) => { tap.test('parses a journeys() response correctly (SBB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journeys = res.outConL.map(j => profile.parseJourney(ctx, j)) const journeys = res.outConL.map(j => profile.parseJourney(ctx, j))
t.deepEqual(journeys, expected) t.same(journeys, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const withThrottling = require('../throttle') const withThrottling = require('../throttle')
@ -10,7 +10,7 @@ const depsRes = require('./fixtures/vbb-departures.json')
const ua = 'public-transport/hafas-client:test' const ua = 'public-transport/hafas-client:test'
const spichernstr = '900000042101' const spichernstr = '900000042101'
test('withThrottling works', {timeout: 2600}, (t) => { tap.test('withThrottling works', {timeout: 3000}, (t) => {
let calls = 0 let calls = 0
const mockedRequest = async (ctx, userAgent, reqData) => { const mockedRequest = async (ctx, userAgent, reqData) => {
calls++ calls++

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/vbb') const rawProfile = require('../p/vbb')
@ -21,11 +21,11 @@ const opt = {
products: {} products: {}
} }
test('parses a departure correctly (VBB)', (t) => { tap.test('parses a departure correctly (VBB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const departures = res.jnyL.map(d => profile.parseDeparture(ctx, d)) const departures = res.jnyL.map(d => profile.parseDeparture(ctx, d))
t.deepEqual(departures, expected) t.same(departures, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/vbb') const rawProfile = require('../p/vbb')
@ -30,11 +30,11 @@ const opt = {
products: {}, products: {},
} }
test('parses a journeys() response correctly (VBB)', (t) => { tap.test('parses a journeys() response correctly (VBB)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const journeys = res.outConL.map(j => profile.parseJourney(ctx, j)) const journeys = res.outConL.map(j => profile.parseJourney(ctx, j))
t.deepEqual(journeys, expected) t.same(journeys, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/vsn') const rawProfile = require('../p/vsn')
@ -28,11 +28,11 @@ const opt = {
// products: {} // products: {}
} }
test('parses departures correctly (VSN)', (t) => { tap.test('parses departures correctly (VSN)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const dep = profile.parseDeparture(ctx, res.jnyL[0]) const dep = profile.parseDeparture(ctx, res.jnyL[0])
t.deepEqual(dep, expected) t.same(dep, expected)
t.end() t.end()
}) })

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const test = require('tape') const tap = require('tap')
const createClient = require('..') const createClient = require('..')
const rawProfile = require('../p/vsn') const rawProfile = require('../p/vsn')
@ -17,11 +17,11 @@ const opt = {
products: null, // filter by affected products products: null, // filter by affected products
} }
test('parses a remarks() response correctly (VSN)', (t) => { tap.test('parses a remarks() response correctly (VSN)', (t) => {
const common = profile.parseCommon({profile, opt, res}) const common = profile.parseCommon({profile, opt, res})
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
const warnings = res.msgL.map(w => profile.parseWarning(ctx, w)) const warnings = res.msgL.map(w => profile.parseWarning(ctx, w))
t.deepEqual(warnings, expected) t.same(warnings, expected)
t.end() t.end()
}) })