mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 23:29:35 +02:00
journeys from station to POI tests: use helper fn
This commit is contained in:
parent
1018369576
commit
9501dab9f4
5 changed files with 75 additions and 80 deletions
36
test/db.js
36
test/db.js
|
@ -17,6 +17,7 @@ const {
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
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 testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||||
|
|
||||||
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
||||||
|
@ -64,7 +65,6 @@ const berlinHbf = '8011160'
|
||||||
const münchenHbf = '8000261'
|
const münchenHbf = '8000261'
|
||||||
const jungfernheide = '8011167'
|
const jungfernheide = '8011167'
|
||||||
const blnSchwedterStr = '732652'
|
const blnSchwedterStr = '732652'
|
||||||
const atze = '991598902'
|
|
||||||
const westhafen = '008089116'
|
const westhafen = '008089116'
|
||||||
const wedding = '008089131'
|
const wedding = '008089131'
|
||||||
const württembergallee = '731084'
|
const württembergallee = '731084'
|
||||||
|
@ -114,23 +114,25 @@ test('Berlin Schwedter Str. to Torfstraße 17', co(function* (t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
|
test('Berlin Schwedter Str. to ATZE Musiktheater', co(function* (t) {
|
||||||
const latitude = 52.542417
|
const atze = {
|
||||||
const longitude = 13.350437
|
type: 'location',
|
||||||
const journeys = yield client.journeys(jungfernheide, {
|
id: '991598902',
|
||||||
type: 'location', id: atze, name: 'ATZE Musiktheater',
|
name: 'ATZE Musiktheater',
|
||||||
latitude, longitude
|
latitude: 52.542417,
|
||||||
}, {when})
|
longitude: 13.350437
|
||||||
|
}
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
const journeys = yield client.journeys(blnSchwedterStr, atze, {
|
||||||
|
results: 3, when
|
||||||
const i = journeys[0].legs.length - 1
|
})
|
||||||
const d = journeys[0].legs[i].destination
|
|
||||||
const name = `journeys[0].legs[${i}].destination`
|
|
||||||
t.equal(d.name, 'ATZE Musiktheater', name + '.name is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), name + '.latitude is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), name + '.longitude is invalid')
|
|
||||||
|
|
||||||
|
yield testJourneysStationToPoi({
|
||||||
|
test: t,
|
||||||
|
journeys,
|
||||||
|
validate,
|
||||||
|
fromId: blnSchwedterStr,
|
||||||
|
to: atze
|
||||||
|
})
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
22
test/insa.js
22
test/insa.js
|
@ -12,6 +12,7 @@ const products = require('../p/insa/products')
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
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 testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||||
|
|
||||||
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
||||||
|
@ -75,7 +76,7 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
|
test('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
|
||||||
const kloster = {
|
const kloster = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '970012223',
|
id: '970012223',
|
||||||
|
@ -83,20 +84,17 @@ test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
|
||||||
latitude: 52.127601,
|
latitude: 52.127601,
|
||||||
longitude: 11.636437
|
longitude: 11.636437
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeys = yield client.journeys(magdeburgHbf, kloster, {
|
const journeys = yield client.journeys(magdeburgHbf, kloster, {
|
||||||
when
|
results: 3, when
|
||||||
})
|
})
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
|
||||||
|
|
||||||
for (let journey of journeys) {
|
yield testJourneysStationToPoi({
|
||||||
const i = journey.legs.length - 1
|
test: t,
|
||||||
const d = journey.legs[i].destination
|
journeys,
|
||||||
t.equal(d.id, kloster.id)
|
validate,
|
||||||
t.equal(d.name, kloster.name)
|
fromId: magdeburgHbf,
|
||||||
t.ok(isRoughlyEqual(0.0001, d.latitude, kloster.latitude))
|
to: kloster
|
||||||
t.ok(isRoughlyEqual(0.0001, d.longitude, kloster.longitude))
|
})
|
||||||
}
|
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ const {
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
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 testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||||
|
|
||||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||||
|
@ -58,7 +59,6 @@ const client = createClient(nahshProfile)
|
||||||
|
|
||||||
const kielHbf = '8000199'
|
const kielHbf = '8000199'
|
||||||
const flensburg = '8000103'
|
const flensburg = '8000103'
|
||||||
const holstentor = '970003547'
|
|
||||||
const luebeckHbf = '8000237'
|
const luebeckHbf = '8000237'
|
||||||
const husum = '8000181'
|
const husum = '8000181'
|
||||||
const schleswig = '8005362'
|
const schleswig = '8005362'
|
||||||
|
@ -110,27 +110,24 @@ test('Kiel Hbf to Husum, Zingel 10', co(function* (t) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('Kiel Hbf to Holstentor', co(function* (t) {
|
test('Kiel Hbf to Holstentor', co(function* (t) {
|
||||||
const latitude = 53.866321
|
const holstentor = {
|
||||||
const longitude = 10.679976
|
|
||||||
const name = 'Hansestadt Lübeck, Holstentor (Denkmal)'
|
|
||||||
const journeys = yield client.journeys(kielHbf, {
|
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: holstentor,
|
id: '970003547',
|
||||||
name,
|
name: 'Hansestadt Lübeck, Holstentor (Denkmal)',
|
||||||
latitude, longitude
|
latitude: 53.866321,
|
||||||
}, {when})
|
longitude: 10.679976
|
||||||
|
}
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
const journeys = yield client.journeys(kielHbf, holstentor, {
|
||||||
|
results: 3, when
|
||||||
const i = journeys[0].legs.length - 1
|
})
|
||||||
const d = journeys[0].legs[i].destination
|
|
||||||
const k = `journeys[0].legs[${i}].destination`
|
|
||||||
|
|
||||||
t.strictEqual(d.id, holstentor, k + '.id is invalid')
|
|
||||||
t.strictEqual(d.name, name, k + '.name is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), k + '.latitude is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), k + '.longitude is invalid')
|
|
||||||
|
|
||||||
|
yield testJourneysStationToPoi({
|
||||||
|
test: t,
|
||||||
|
journeys,
|
||||||
|
validate,
|
||||||
|
fromId: kielHbf,
|
||||||
|
to: holstentor
|
||||||
|
})
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
26
test/oebb.js
26
test/oebb.js
|
@ -16,6 +16,7 @@ const {
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
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 testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||||
|
|
||||||
const when = createWhen('Europe/Vienna', 'de-AT')
|
const when = createWhen('Europe/Vienna', 'de-AT')
|
||||||
|
@ -101,25 +102,24 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('Salzburg Hbf to Albertina', co(function* (t) {
|
test('Salzburg Hbf to Albertina', co(function* (t) {
|
||||||
const latitude = 48.204699
|
|
||||||
const longitude = 16.368404
|
|
||||||
const albertina = {
|
const albertina = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '975900003',
|
id: '975900003',
|
||||||
name: 'Albertina',
|
name: 'Albertina',
|
||||||
latitude, longitude
|
latitude: 48.204699,
|
||||||
|
longitude: 16.368404
|
||||||
}
|
}
|
||||||
const journeys = yield client.journeys(salzburgHbf, albertina, {when})
|
const journeys = yield client.journeys(salzburgHbf, albertina, {
|
||||||
|
results: 3, when
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
})
|
||||||
|
|
||||||
const i = journeys[0].legs.length - 1
|
|
||||||
const d = journeys[0].legs[i].destination
|
|
||||||
const k = `journeys[0].legs[${i}].destination`
|
|
||||||
t.equal(d.name, 'Albertina', k + '.name is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), k + '.latitude is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), k + '.longitude is invalid')
|
|
||||||
|
|
||||||
|
yield testJourneysStationToPoi({
|
||||||
|
test: t,
|
||||||
|
journeys,
|
||||||
|
validate,
|
||||||
|
fromId: salzburgHbf,
|
||||||
|
to: albertina
|
||||||
|
})
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
34
test/vbb.js
34
test/vbb.js
|
@ -22,6 +22,7 @@ const {
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
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 testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||||
|
|
||||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||||
|
@ -100,7 +101,6 @@ const client = createClient(vbbProfile)
|
||||||
const amrumerStr = '900000009101'
|
const amrumerStr = '900000009101'
|
||||||
const spichernstr = '900000042101'
|
const spichernstr = '900000042101'
|
||||||
const bismarckstr = '900000024201'
|
const bismarckstr = '900000024201'
|
||||||
const atze = '900980720'
|
|
||||||
const westhafen = '900000001201'
|
const westhafen = '900000001201'
|
||||||
const wedding = '900000009104'
|
const wedding = '900000009104'
|
||||||
const württembergallee = '900000026153'
|
const württembergallee = '900000026153'
|
||||||
|
@ -229,26 +229,24 @@ test('journeys – station to address', co(function* (t) {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('journeys – station to POI', co(function* (t) {
|
test('journeys – station to POI', co(function* (t) {
|
||||||
const latitude = 52.543333
|
const atze = {
|
||||||
const longitude = 13.351686
|
|
||||||
const journeys = yield client.journeys(spichernstr, {
|
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: atze,
|
id: '900980720',
|
||||||
name: 'Berlin, Atze Musiktheater für Kinder',
|
name: 'Berlin, Atze Musiktheater für Kinder',
|
||||||
latitude, longitude
|
latitude: 52.543333,
|
||||||
}, {results: 1, when})
|
longitude: 13.351686
|
||||||
|
}
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
const journeys = yield client.journeys(spichernstr, atze, {
|
||||||
|
results: 3, when
|
||||||
const i = journeys[0].legs.length - 1
|
})
|
||||||
const d = journeys[0].legs[i].destination
|
|
||||||
const name = `journeys[0].legs[${i}].destination`
|
|
||||||
|
|
||||||
t.strictEqual(d.id, atze, name + '.id is invalid')
|
|
||||||
t.strictEqual(d.name, 'Berlin, Atze Musiktheater für Kinder', name + '.name is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.latitude, latitude), name + '.latitude is invalid')
|
|
||||||
t.ok(isRoughlyEqual(.0001, d.longitude, longitude), name + '.longitude is invalid')
|
|
||||||
|
|
||||||
|
yield testJourneysStationToPoi({
|
||||||
|
test: t,
|
||||||
|
journeys,
|
||||||
|
validate,
|
||||||
|
fromId: spichernstr,
|
||||||
|
to: atze
|
||||||
|
})
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue