mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
adapt tests to fcc53b5
✅
This commit is contained in:
parent
b2b2d11dfe
commit
a1c40ad084
17 changed files with 154 additions and 137 deletions
33
test/bvg.js
33
test/bvg.js
|
@ -66,7 +66,7 @@ const jannowitzbrücke = '900000100004'
|
||||||
const hour = 60 * 60 * 1000
|
const hour = 60 * 60 * 1000
|
||||||
|
|
||||||
test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
const journeys = await client.journeys(spichernstr, bismarckstr, {
|
const res = await client.journeys(spichernstr, bismarckstr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -74,7 +74,7 @@ test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
toId: bismarckstr
|
toId: bismarckstr
|
||||||
|
@ -85,7 +85,7 @@ test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('journeys – only subway', async (t) => {
|
test('journeys – only subway', async (t) => {
|
||||||
const journeys = await client.journeys(spichernstr, bismarckstr, {
|
const res = await client.journeys(spichernstr, bismarckstr, {
|
||||||
results: 20,
|
results: 20,
|
||||||
departure: when,
|
departure: when,
|
||||||
products: {
|
products: {
|
||||||
|
@ -99,14 +99,15 @@ test('journeys – only subway', async (t) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
t.ok(journeys.length > 1)
|
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
t.ok(res.journeys.length > 1)
|
||||||
const journey = journeys[i]
|
for (let i = 0; i < res.journeys.length; i++) {
|
||||||
|
const journey = res.journeys[i]
|
||||||
for (let j = 0; j < journey.legs.length; j++) {
|
for (let j = 0; j < journey.legs.length; j++) {
|
||||||
const leg = journey.legs[j]
|
const leg = journey.legs[j]
|
||||||
|
|
||||||
const name = `journeys[${i}].legs[${j}].line`
|
const name = `res.journeys[${i}].legs[${j}].line`
|
||||||
if (leg.line) {
|
if (leg.line) {
|
||||||
t.equal(leg.line.mode, 'train', name + '.mode is invalid')
|
t.equal(leg.line.mode, 'train', name + '.mode is invalid')
|
||||||
t.equal(leg.line.product, 'subway', name + '.product is invalid')
|
t.equal(leg.line.product, 'subway', name + '.product is invalid')
|
||||||
|
@ -166,11 +167,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(spichernstr, amrumerStr, {
|
const res = await client.journeys(spichernstr, amrumerStr, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
@ -186,14 +187,14 @@ test('journeys – station to address', async (t) => {
|
||||||
latitude: 52.541797,
|
latitude: 52.541797,
|
||||||
longitude: 13.350042
|
longitude: 13.350042
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(spichernstr, torfstr, {
|
const res = await client.journeys(spichernstr, torfstr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
to: torfstr
|
to: torfstr
|
||||||
|
@ -209,14 +210,14 @@ test('journeys – station to POI', async (t) => {
|
||||||
latitude: 52.543333,
|
latitude: 52.543333,
|
||||||
longitude: 13.351686
|
longitude: 13.351686
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(spichernstr, atze, {
|
const res = await client.journeys(spichernstr, atze, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
to: atze
|
to: atze
|
||||||
|
@ -227,7 +228,7 @@ test('journeys – station to POI', async (t) => {
|
||||||
test('journeys: via works – with detour', async (t) => {
|
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 journeys = await client.journeys(westhafen, wedding, {
|
const res = await client.journeys(westhafen, wedding, {
|
||||||
via: württembergallee,
|
via: württembergallee,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -236,7 +237,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [württembergallee]
|
detourIds: [württembergallee]
|
||||||
})
|
})
|
||||||
|
|
16
test/cmta.js
16
test/cmta.js
|
@ -42,7 +42,7 @@ const domain = '5919'
|
||||||
const capitol591 = '591'
|
const capitol591 = '591'
|
||||||
|
|
||||||
test('journeys – Broadie Oaks to Domain', async (t) => {
|
test('journeys – Broadie Oaks to Domain', async (t) => {
|
||||||
const journeys = await client.journeys(broadieOaks, domain, {
|
const res = await client.journeys(broadieOaks, domain, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -50,7 +50,7 @@ test('journeys – Broadie Oaks to Domain', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: broadieOaks,
|
fromId: broadieOaks,
|
||||||
toId: domain
|
toId: domain
|
||||||
|
@ -80,14 +80,14 @@ test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => {
|
||||||
longitude: -97.758292
|
longitude: -97.758292
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeys = await client.journeys(domain, someAddress, {
|
const res = await client.journeys(domain, someAddress, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: domain,
|
fromId: domain,
|
||||||
to: someAddress
|
to: someAddress
|
||||||
|
@ -103,14 +103,14 @@ test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
|
||||||
latitude: 30.270653,
|
latitude: 30.270653,
|
||||||
longitude: -97.753564
|
longitude: -97.753564
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(domain, wholeFoodsMarket, {
|
const res = await client.journeys(domain, wholeFoodsMarket, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: domain,
|
fromId: domain,
|
||||||
to: wholeFoodsMarket
|
to: wholeFoodsMarket
|
||||||
|
@ -148,11 +148,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(broadieOaks, domain, {
|
const res = await client.journeys(broadieOaks, domain, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
22
test/db.js
22
test/db.js
|
@ -88,7 +88,7 @@ const blnJannowitzbrücke = '8089019'
|
||||||
const potsdamHbf = '8012666'
|
const potsdamHbf = '8012666'
|
||||||
|
|
||||||
test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => {
|
test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => {
|
||||||
const journeys = await client.journeys(blnSchwedterStr, münchenHbf, {
|
const res = await client.journeys(blnSchwedterStr, münchenHbf, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -96,13 +96,13 @@ test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: blnSchwedterStr,
|
fromId: blnSchwedterStr,
|
||||||
toId: münchenHbf
|
toId: münchenHbf
|
||||||
})
|
})
|
||||||
// todo: find a journey where there pricing info is always available
|
// todo: find a journey where there pricing info is always available
|
||||||
for (let journey of journeys) {
|
for (let journey of res.journeys) {
|
||||||
if (journey.price) assertValidPrice(t, journey.price)
|
if (journey.price) assertValidPrice(t, journey.price)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,14 +130,14 @@ test('Berlin Schwedter Str. to Torfstraße 17', async (t) => {
|
||||||
latitude: 52.5416823,
|
latitude: 52.5416823,
|
||||||
longitude: 13.3491223
|
longitude: 13.3491223
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(blnSchwedterStr, torfstr, {
|
const res = await client.journeys(blnSchwedterStr, torfstr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: blnSchwedterStr,
|
fromId: blnSchwedterStr,
|
||||||
to: torfstr
|
to: torfstr
|
||||||
|
@ -153,14 +153,14 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
|
||||||
latitude: 52.542417,
|
latitude: 52.542417,
|
||||||
longitude: 13.350437
|
longitude: 13.350437
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(blnSchwedterStr, atze, {
|
const res = await client.journeys(blnSchwedterStr, atze, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: blnSchwedterStr,
|
fromId: blnSchwedterStr,
|
||||||
to: atze
|
to: atze
|
||||||
|
@ -171,7 +171,7 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
|
||||||
test('journeys: via works – with detour', async (t) => {
|
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 journeys = await client.journeys(westhafen, wedding, {
|
const res = await client.journeys(westhafen, wedding, {
|
||||||
via: württembergallee,
|
via: württembergallee,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -180,7 +180,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [württembergallee]
|
detourIds: [württembergallee]
|
||||||
})
|
})
|
||||||
|
@ -226,11 +226,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(berlinHbf, münchenHbf, {
|
const res = await client.journeys(berlinHbf, münchenHbf, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
20
test/insa.js
20
test/insa.js
|
@ -47,7 +47,7 @@ const dessau = '8010077'
|
||||||
const universitaet = '19686'
|
const universitaet = '19686'
|
||||||
|
|
||||||
test('journeys – Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
|
test('journeys – Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
|
||||||
const journeys = await client.journeys(magdeburgHbf, magdeburgBuckau, {
|
const res = await client.journeys(magdeburgHbf, magdeburgBuckau, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -55,7 +55,7 @@ test('journeys – Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: magdeburgHbf,
|
fromId: magdeburgHbf,
|
||||||
toId: magdeburgBuckau
|
toId: magdeburgBuckau
|
||||||
|
@ -85,14 +85,14 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
|
||||||
longitude: 11.422332
|
longitude: 11.422332
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeys = await client.journeys(magdeburgHbf, sternStr, {
|
const res = await client.journeys(magdeburgHbf, sternStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: magdeburgHbf,
|
fromId: magdeburgHbf,
|
||||||
to: sternStr
|
to: sternStr
|
||||||
|
@ -108,14 +108,14 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
|
||||||
latitude: 52.127601,
|
latitude: 52.127601,
|
||||||
longitude: 11.636437
|
longitude: 11.636437
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(magdeburgHbf, kloster, {
|
const res = await client.journeys(magdeburgHbf, kloster, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: magdeburgHbf,
|
fromId: magdeburgHbf,
|
||||||
to: kloster
|
to: kloster
|
||||||
|
@ -127,7 +127,7 @@ 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.
|
||||||
const journeys = await client.journeys(hasselbachplatzSternstrasse, stendal, {
|
const res = await client.journeys(hasselbachplatzSternstrasse, stendal, {
|
||||||
via: dessau,
|
via: dessau,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -136,7 +136,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [dessau]
|
detourIds: [dessau]
|
||||||
})
|
})
|
||||||
|
@ -159,11 +159,11 @@ test('earlier/later journeys', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(magdeburgHbf, magdeburgBuckau, {
|
const res = await client.journeys(magdeburgHbf, magdeburgBuckau, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
|
@ -51,7 +51,7 @@ const testEarlierLaterJourneys = async (cfg) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
let earliestDep = Infinity, latestDep = -Infinity
|
let earliestDep = Infinity, latestDep = -Infinity
|
||||||
for (let j of model) {
|
for (let j of model.journeys) {
|
||||||
if (j.legs[0].departure === null) continue
|
if (j.legs[0].departure === null) continue
|
||||||
const dep = +new Date(j.legs[0].departure)
|
const dep = +new Date(j.legs[0].departure)
|
||||||
if (dep < earliestDep) earliestDep = dep
|
if (dep < earliestDep) earliestDep = dep
|
||||||
|
@ -63,7 +63,7 @@ const testEarlierLaterJourneys = async (cfg) => {
|
||||||
// todo: single journey ref?
|
// todo: single journey ref?
|
||||||
earlierThan: model.earlierRef
|
earlierThan: model.earlierRef
|
||||||
})
|
})
|
||||||
for (let j of earlier) {
|
for (let j of earlier.journeys) {
|
||||||
const firstLeg = j.legs[0]
|
const firstLeg = j.legs[0]
|
||||||
const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
|
const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
|
||||||
t.ok(dep < earliestDep)
|
t.ok(dep < earliestDep)
|
||||||
|
@ -74,7 +74,7 @@ const testEarlierLaterJourneys = async (cfg) => {
|
||||||
// todo: single journey ref?
|
// todo: single journey ref?
|
||||||
laterThan: model.laterRef
|
laterThan: model.laterRef
|
||||||
})
|
})
|
||||||
for (let j of later) {
|
for (let j of later.journeys) {
|
||||||
const firstLeg = j.legs[0]
|
const firstLeg = j.legs[0]
|
||||||
const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
|
const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
|
||||||
t.ok(dep > latestDep)
|
t.ok(dep > latestDep)
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
const isRoughlyEqual = require('is-roughly-equal')
|
const isRoughlyEqual = require('is-roughly-equal')
|
||||||
|
|
||||||
const testJourneysStationToAddress = async (cfg) => {
|
const testJourneysStationToAddress = async (cfg) => {
|
||||||
const {test: t, journeys, validate, fromId} = cfg
|
const {test: t, res, validate, fromId} = cfg
|
||||||
const {address, latitude, longitude} = cfg.to
|
const {address, latitude, longitude} = cfg.to
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
const {journeys} = res
|
||||||
|
|
||||||
t.strictEqual(journeys.length, 3)
|
t.strictEqual(journeys.length, 3)
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
for (let i = 0; i < journeys.length; i++) {
|
||||||
const j = journeys[i]
|
const j = journeys[i]
|
||||||
|
@ -16,7 +18,7 @@ const testJourneysStationToAddress = async (cfg) => {
|
||||||
t.ok(orig.id, fromId)
|
t.ok(orig.id, fromId)
|
||||||
|
|
||||||
const d = j.legs[j.legs.length - 1].destination
|
const d = j.legs[j.legs.length - 1].destination
|
||||||
const n = `journeys[0].legs[${i}].destination`
|
const n = `res.journeys[0].legs[${i}].destination`
|
||||||
|
|
||||||
t.strictEqual(d.type, 'location', n + '.type is invalid')
|
t.strictEqual(d.type, 'location', n + '.type is invalid')
|
||||||
t.strictEqual(d.address, address, n + '.address is invalid')
|
t.strictEqual(d.address, address, n + '.address is invalid')
|
||||||
|
|
|
@ -3,16 +3,18 @@
|
||||||
const isRoughlyEqual = require('is-roughly-equal')
|
const isRoughlyEqual = require('is-roughly-equal')
|
||||||
|
|
||||||
const testJourneysStationToPoi = async (cfg) => {
|
const testJourneysStationToPoi = async (cfg) => {
|
||||||
const {test: t, journeys, validate, fromId} = cfg
|
const {test: t, res, validate, fromId} = cfg
|
||||||
const {id, name, latitude, longitude} = cfg.to
|
const {id, name, latitude, longitude} = cfg.to
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
const {journeys} = res
|
||||||
|
|
||||||
t.strictEqual(journeys.length, 3)
|
t.strictEqual(journeys.length, 3)
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
for (let i = 0; i < journeys.length; i++) {
|
||||||
const j = journeys[i]
|
const j = journeys[i]
|
||||||
|
|
||||||
let o = j.legs[0].origin
|
let o = j.legs[0].origin
|
||||||
let oN = `journeys[0].legs[0].destination`
|
let oN = `res.journeys[0].legs[0].destination`
|
||||||
if (o.station) {
|
if (o.station) {
|
||||||
o = o.station
|
o = o.station
|
||||||
oN += '.station'
|
oN += '.station'
|
||||||
|
@ -20,7 +22,7 @@ const testJourneysStationToPoi = async (cfg) => {
|
||||||
t.strictEqual(o.id, fromId)
|
t.strictEqual(o.id, fromId)
|
||||||
|
|
||||||
let d = j.legs[j.legs.length - 1].destination
|
let d = j.legs[j.legs.length - 1].destination
|
||||||
let dN = `journeys[${i}].legs[${j.legs.length - 1}].destination`
|
let dN = `res.journeys[${i}].legs[${j.legs.length - 1}].destination`
|
||||||
if (d.station) {
|
if (d.station) {
|
||||||
d = d.station
|
d = d.station
|
||||||
dN += '.station'
|
dN += '.station'
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const testJourneysStationToStation = async (cfg) => {
|
const testJourneysStationToStation = async (cfg) => {
|
||||||
const {test: t, journeys, validate, fromId, toId} = cfg
|
const {test: t, res, validate, fromId, toId} = cfg
|
||||||
|
|
||||||
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
const {journeys} = res
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
|
||||||
t.strictEqual(journeys.length, 3)
|
t.strictEqual(journeys.length, 3)
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
for (let i = 0; i < journeys.length; i++) {
|
||||||
const j = journeys[i]
|
const j = journeys[i]
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const testJourneysWithDetour = async (cfg) => {
|
const testJourneysWithDetour = async (cfg) => {
|
||||||
const {test: t, journeys, validate, detourIds} = cfg
|
const {test: t, res, validate, detourIds} = cfg
|
||||||
|
|
||||||
// We assume that going from A to B via C *without* detour is currently
|
// We assume that going from A to B via C *without* detour is currently
|
||||||
// impossible. We check if the routing engine computes a detour.
|
// impossible. We check if the routing engine computes a detour.
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
const {journeys} = res
|
||||||
|
|
||||||
const leg = journeys[0].legs.some((leg) => {
|
const leg = journeys[0].legs.some((leg) => {
|
||||||
return leg.stopovers && leg.stopovers.some((st) => (
|
return leg.stopovers && leg.stopovers.some((st) => (
|
||||||
|
|
|
@ -31,10 +31,11 @@ const testRefreshJourney = async (cfg) => {
|
||||||
// todo: validate
|
// todo: validate
|
||||||
} = cfg
|
} = cfg
|
||||||
|
|
||||||
const [model] = await fetchJourneys(fromId, toId, {
|
const modelRes = await fetchJourneys(fromId, toId, {
|
||||||
results: 1, departure: when,
|
results: 1, departure: when,
|
||||||
stopovers: false
|
stopovers: false
|
||||||
})
|
})
|
||||||
|
const [model] = modelRes.journeys
|
||||||
|
|
||||||
// todo: move to journeys validator?
|
// todo: move to journeys validator?
|
||||||
t.equal(typeof model.refreshToken, 'string')
|
t.equal(typeof model.refreshToken, 'string')
|
||||||
|
|
|
@ -304,6 +304,12 @@ const validateJourneys = (val, js, name = 'journeys') => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const validateJourneysResult = (val, res, name = 'journeysResult') => {
|
||||||
|
a.ok(isObj(res), name + ' must be an object')
|
||||||
|
// todo: `earlierRef`, `laterRef`
|
||||||
|
val.journeys(val, res.journeys, name + '.journeys')
|
||||||
|
}
|
||||||
|
|
||||||
const validateTrip = (val, trip, name = 'trip') => {
|
const validateTrip = (val, trip, name = 'trip') => {
|
||||||
const withFakeTripId = Object.assign({
|
const withFakeTripId = Object.assign({
|
||||||
tripId: trip.id
|
tripId: trip.id
|
||||||
|
@ -458,6 +464,7 @@ module.exports = {
|
||||||
journeyLeg: createValidateJourneyLeg,
|
journeyLeg: createValidateJourneyLeg,
|
||||||
journey: () => validateJourney,
|
journey: () => validateJourney,
|
||||||
journeys: () => validateJourneys,
|
journeys: () => validateJourneys,
|
||||||
|
journeysResult: () => validateJourneysResult,
|
||||||
trip: () => validateTrip,
|
trip: () => validateTrip,
|
||||||
arrival: createValidateArrival,
|
arrival: createValidateArrival,
|
||||||
departure: createValidateDeparture,
|
departure: createValidateDeparture,
|
||||||
|
|
|
@ -76,7 +76,7 @@ const seefischmarkt = '9049245'
|
||||||
const kielRaeucherei = '9049217'
|
const kielRaeucherei = '9049217'
|
||||||
|
|
||||||
test('journeys – Kiel Hbf to Flensburg', async (t) => {
|
test('journeys – Kiel Hbf to Flensburg', async (t) => {
|
||||||
const journeys = await client.journeys(kielHbf, flensburg, {
|
const res = await client.journeys(kielHbf, flensburg, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -84,16 +84,16 @@ test('journeys – Kiel Hbf to Flensburg', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: kielHbf,
|
fromId: kielHbf,
|
||||||
toId: flensburg
|
toId: flensburg
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
for (let i = 0; i < res.journeys.length; i++) {
|
||||||
const j = journeys[i]
|
const j = res.journeys[i]
|
||||||
// todo: find a journey where there pricing info is always available
|
// todo: find a journey where there pricing info is always available
|
||||||
if (j.price) assertValidPrice(t, j.price, `journeys[${i}].price`)
|
if (j.price) assertValidPrice(t, j.price, `res.journeys[${i}].price`)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
@ -120,14 +120,14 @@ test('Kiel Hbf to Berliner Str. 80, Husum', async (t) => {
|
||||||
latitude: 54.488995,
|
latitude: 54.488995,
|
||||||
longitude: 9.056263
|
longitude: 9.056263
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(kielHbf, berlinerStr, {
|
const res = await client.journeys(kielHbf, berlinerStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: kielHbf,
|
fromId: kielHbf,
|
||||||
to: berlinerStr
|
to: berlinerStr
|
||||||
|
@ -143,14 +143,14 @@ test('Kiel Hbf to Holstentor', async (t) => {
|
||||||
latitude: 53.866321,
|
latitude: 53.866321,
|
||||||
longitude: 10.679976
|
longitude: 10.679976
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(kielHbf, holstentor, {
|
const res = await client.journeys(kielHbf, holstentor, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: kielHbf,
|
fromId: kielHbf,
|
||||||
to: holstentor
|
to: holstentor
|
||||||
|
@ -159,16 +159,16 @@ test('Kiel Hbf to Holstentor', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => {
|
test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => {
|
||||||
const journeys = await client.journeys(husum, luebeckHbf, {
|
const res = await client.journeys(husum, luebeckHbf, {
|
||||||
via: kielHbf,
|
via: kielHbf,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
|
||||||
const leg = journeys[0].legs.some((leg) => {
|
const leg = res.journeys[0].legs.some((leg) => {
|
||||||
return leg.stopovers && leg.stopovers.some((stopover) => {
|
return leg.stopovers && leg.stopovers.some((stopover) => {
|
||||||
const s = stopover.stop
|
const s = stopover.stop
|
||||||
return s.station && s.station.id === kielHbf || s.id === kielHbf
|
return s.station && s.station.id === kielHbf || s.id === kielHbf
|
||||||
|
@ -209,11 +209,11 @@ test('refreshJourney', async (t) => {
|
||||||
// todo: without detour test
|
// todo: without detour test
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(flensburg, husum, {
|
const res = await client.journeys(flensburg, husum, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
34
test/oebb.js
34
test/oebb.js
|
@ -67,7 +67,7 @@ const wienKarlsplatz = '1390461'
|
||||||
const wienPilgramgasse = '1390562'
|
const wienPilgramgasse = '1390562'
|
||||||
|
|
||||||
test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', async (t) => {
|
test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', async (t) => {
|
||||||
const journeys = await client.journeys(salzburgHbf, wienFickeystr, {
|
const res = await client.journeys(salzburgHbf, wienFickeystr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -75,15 +75,15 @@ test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: salzburgHbf,
|
fromId: salzburgHbf,
|
||||||
toId: wienFickeystr
|
toId: wienFickeystr
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
for (let i = 0; i < res.journeys.length; i++) {
|
||||||
const j = journeys[i]
|
const j = res.journeys[i]
|
||||||
if (j.price) assertValidPrice(t, j.price, `journeys[${i}].price`)
|
if (j.price) assertValidPrice(t, j.price, `res.journeys[${i}].price`)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
@ -110,14 +110,14 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', async (t) => {
|
||||||
latitude: 48.236216,
|
latitude: 48.236216,
|
||||||
longitude: 16.425863
|
longitude: 16.425863
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(salzburgHbf, wagramerStr, {
|
const res = await client.journeys(salzburgHbf, wagramerStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: salzburgHbf,
|
fromId: salzburgHbf,
|
||||||
to: wagramerStr
|
to: wagramerStr
|
||||||
|
@ -133,13 +133,13 @@ test('Salzburg Hbf to Albertina', async (t) => {
|
||||||
latitude: 48.204699,
|
latitude: 48.204699,
|
||||||
longitude: 16.368404
|
longitude: 16.368404
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(salzburgHbf, albertina, {
|
const res = await client.journeys(salzburgHbf, albertina, {
|
||||||
results: 3, departure: when
|
results: 3, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: salzburgHbf,
|
fromId: salzburgHbf,
|
||||||
to: albertina
|
to: albertina
|
||||||
|
@ -154,7 +154,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
const schottenring = '1390163'
|
const schottenring = '1390163'
|
||||||
const donauinsel = '1392277'
|
const donauinsel = '1392277'
|
||||||
const donauinselPassed = '922001'
|
const donauinselPassed = '922001'
|
||||||
const journeys = await client.journeys(stephansplatz, schottenring, {
|
const res = await client.journeys(stephansplatz, schottenring, {
|
||||||
via: donauinsel,
|
via: donauinsel,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -163,7 +163,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [donauinsel, donauinselPassed]
|
detourIds: [donauinsel, donauinselPassed]
|
||||||
})
|
})
|
||||||
|
@ -178,16 +178,16 @@ test('journeys: via works – without detour', async (t) => {
|
||||||
const museumsquartier = '1390171'
|
const museumsquartier = '1390171'
|
||||||
const museumsquartierPassed = '901014'
|
const museumsquartierPassed = '901014'
|
||||||
|
|
||||||
const journeys = await client.journeys(karlsplatz, praterstern, {
|
const res = await client.journeys(karlsplatz, praterstern, {
|
||||||
via: museumsquartier,
|
via: museumsquartier,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
|
||||||
const l1 = journeys[0].legs.some((leg) => {
|
const l1 = res.journeys[0].legs.some((leg) => {
|
||||||
return (
|
return (
|
||||||
leg.destination.id === museumsquartier ||
|
leg.destination.id === museumsquartier ||
|
||||||
leg.destination.id === museumsquartierPassed
|
leg.destination.id === museumsquartierPassed
|
||||||
|
@ -195,7 +195,7 @@ test('journeys: via works – without detour', async (t) => {
|
||||||
})
|
})
|
||||||
t.notOk(l1, 'transfer at Museumsquartier')
|
t.notOk(l1, 'transfer at Museumsquartier')
|
||||||
|
|
||||||
const l2 = journeys[0].legs.some((leg) => {
|
const l2 = res.journeys[0].legs.some((leg) => {
|
||||||
return leg.stopovers && leg.stopovers.some((stopover) => {
|
return leg.stopovers && leg.stopovers.some((stopover) => {
|
||||||
return stopover.stop.id === museumsquartierPassed
|
return stopover.stop.id === museumsquartierPassed
|
||||||
})
|
})
|
||||||
|
@ -232,11 +232,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(wienWestbahnhof, muenchenHbf, {
|
const res = await client.journeys(wienWestbahnhof, muenchenHbf, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
|
@ -84,14 +84,14 @@ test('journeys – fails with no product', (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
|
test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
|
||||||
const journeys = await client.journeys(saarbrueckenHbf, thomasMannStr, {
|
const res = await client.journeys(saarbrueckenHbf, thomasMannStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: saarbrueckenHbf,
|
fromId: saarbrueckenHbf,
|
||||||
to: thomasMannStr
|
to: thomasMannStr
|
||||||
|
@ -107,13 +107,13 @@ test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
|
||||||
name: 'Homburg, Schlossberghöhlen',
|
name: 'Homburg, Schlossberghöhlen',
|
||||||
id: '9000185'
|
id: '9000185'
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(saarbrueckenHbf, schlossberghoehlen, {
|
const res = await client.journeys(saarbrueckenHbf, schlossberghoehlen, {
|
||||||
results: 3, departure: when
|
results: 3, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: saarbrueckenHbf,
|
fromId: saarbrueckenHbf,
|
||||||
to: schlossberghoehlen
|
to: schlossberghoehlen
|
||||||
|
@ -128,7 +128,7 @@ test.skip('journeys: via works – with detour', async (t) => {
|
||||||
const schottenring = '1390163'
|
const schottenring = '1390163'
|
||||||
const donauinsel = '1392277'
|
const donauinsel = '1392277'
|
||||||
const donauinselPassed = '922001'
|
const donauinselPassed = '922001'
|
||||||
const journeys = await client.journeys(stephansplatz, schottenring, {
|
const res = await client.journeys(stephansplatz, schottenring, {
|
||||||
via: donauinsel,
|
via: donauinsel,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -137,7 +137,7 @@ test.skip('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [donauinsel, donauinselPassed]
|
detourIds: [donauinsel, donauinselPassed]
|
||||||
})
|
})
|
||||||
|
@ -152,16 +152,16 @@ test.skip('journeys: via works – without detour', async (t) => {
|
||||||
const museumsquartier = '1390171'
|
const museumsquartier = '1390171'
|
||||||
const museumsquartierPassed = '901014'
|
const museumsquartierPassed = '901014'
|
||||||
|
|
||||||
const journeys = await client.journeys(karlsplatz, praterstern, {
|
const res = await client.journeys(karlsplatz, praterstern, {
|
||||||
via: museumsquartier,
|
via: museumsquartier,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
|
|
||||||
const l1 = journeys[0].legs.some((leg) => {
|
const l1 = res.journeys[0].legs.some((leg) => {
|
||||||
return (
|
return (
|
||||||
leg.destination.id === museumsquartier ||
|
leg.destination.id === museumsquartier ||
|
||||||
leg.destination.id === museumsquartierPassed
|
leg.destination.id === museumsquartierPassed
|
||||||
|
@ -169,7 +169,7 @@ test.skip('journeys: via works – without detour', async (t) => {
|
||||||
})
|
})
|
||||||
t.notOk(l1, 'transfer at Museumsquartier')
|
t.notOk(l1, 'transfer at Museumsquartier')
|
||||||
|
|
||||||
const l2 = journeys[0].legs.some((leg) => {
|
const l2 = res.journeys[0].legs.some((leg) => {
|
||||||
return leg.stopovers && leg.stopovers.some((stopover) => {
|
return leg.stopovers && leg.stopovers.some((stopover) => {
|
||||||
return stopover.stop.id === museumsquartierPassed
|
return stopover.stop.id === museumsquartierPassed
|
||||||
})
|
})
|
||||||
|
@ -193,11 +193,11 @@ test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(saarlouisHbf, metzVille, {
|
const res = await client.journeys(saarlouisHbf, metzVille, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, { when })
|
const trip = await client.trip(p.tripId, p.line.name, { when })
|
||||||
|
|
|
@ -63,7 +63,7 @@ const poetschnerstr = {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('journeys – Mittersendling to Karl-Theodor-Straße', async (t) => {
|
test('journeys – Mittersendling to Karl-Theodor-Straße', async (t) => {
|
||||||
const journeys = await client.journeys(mittersendling, karlTheodorStr, {
|
const res = await client.journeys(mittersendling, karlTheodorStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -71,7 +71,7 @@ test('journeys – Mittersendling to Karl-Theodor-Straße', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: mittersendling,
|
fromId: mittersendling,
|
||||||
toId: karlTheodorStr
|
toId: karlTheodorStr
|
||||||
|
@ -94,14 +94,14 @@ test('journeys – fails with no product', (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => {
|
test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => {
|
||||||
const journeys = await client.journeys(karlTheodorStr, poetschnerstr, {
|
const res = await client.journeys(karlTheodorStr, poetschnerstr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: karlTheodorStr,
|
fromId: karlTheodorStr,
|
||||||
to: poetschnerstr
|
to: poetschnerstr
|
||||||
|
@ -117,14 +117,14 @@ test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
|
||||||
latitude: 48.137739,
|
latitude: 48.137739,
|
||||||
longitude: 11.579823
|
longitude: 11.579823
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(karlTheodorStr, hofbraeuhaus, {
|
const res = await client.journeys(karlTheodorStr, hofbraeuhaus, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: karlTheodorStr,
|
fromId: karlTheodorStr,
|
||||||
to: hofbraeuhaus
|
to: hofbraeuhaus
|
||||||
|
@ -162,11 +162,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(mittersendling, karlTheodorStr, {
|
const res = await client.journeys(mittersendling, karlTheodorStr, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs.find(leg => leg.line)
|
const p = res.journeys[0].legs.find(leg => leg.line)
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
33
test/vbb.js
33
test/vbb.js
|
@ -49,7 +49,7 @@ const wedding = '900000009104'
|
||||||
const württembergallee = '900000026153'
|
const württembergallee = '900000026153'
|
||||||
|
|
||||||
test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
const journeys = await client.journeys({
|
const res = await client.journeys({
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: spichernstr,
|
id: spichernstr,
|
||||||
name: 'U Spichernstr.'
|
name: 'U Spichernstr.'
|
||||||
|
@ -61,7 +61,7 @@ test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
toId: bismarckstr
|
toId: bismarckstr
|
||||||
|
@ -72,7 +72,7 @@ test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('journeys – only subway', async (t) => {
|
test('journeys – only subway', async (t) => {
|
||||||
const journeys = await client.journeys(spichernstr, bismarckstr, {
|
const res = await client.journeys(spichernstr, bismarckstr, {
|
||||||
results: 20,
|
results: 20,
|
||||||
departure: when,
|
departure: when,
|
||||||
products: {
|
products: {
|
||||||
|
@ -86,14 +86,15 @@ test('journeys – only subway', async (t) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
validate(t, journeys, 'journeys', 'journeys')
|
validate(t, res, 'journeysResult', 'res')
|
||||||
t.ok(journeys.length > 1)
|
|
||||||
for (let i = 0; i < journeys.length; i++) {
|
t.ok(res.journeys.length > 1)
|
||||||
const journey = journeys[i]
|
for (let i = 0; i < res.journeys.length; i++) {
|
||||||
|
const journey = res.journeys[i]
|
||||||
for (let j = 0; j < journey.legs.length; j++) {
|
for (let j = 0; j < journey.legs.length; j++) {
|
||||||
const leg = journey.legs[j]
|
const leg = journey.legs[j]
|
||||||
|
|
||||||
const name = `journeys[${i}].legs[${i}].line`
|
const name = `res.journeys[${i}].legs[${i}].line`
|
||||||
if (leg.line) {
|
if (leg.line) {
|
||||||
t.equal(leg.line.mode, 'train', name + '.mode is invalid')
|
t.equal(leg.line.mode, 'train', name + '.mode is invalid')
|
||||||
t.equal(leg.line.product, 'subway', name + '.product is invalid')
|
t.equal(leg.line.product, 'subway', name + '.product is invalid')
|
||||||
|
@ -146,11 +147,11 @@ test('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('trip details', async (t) => {
|
test('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(spichernstr, amrumerStr, {
|
const res = await client.journeys(spichernstr, amrumerStr, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
@ -166,14 +167,14 @@ test('journeys – station to address', async (t) => {
|
||||||
latitude: 52.541797,
|
latitude: 52.541797,
|
||||||
longitude: 13.350042
|
longitude: 13.350042
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(spichernstr, torfstr, {
|
const res = await client.journeys(spichernstr, torfstr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
to: torfstr
|
to: torfstr
|
||||||
|
@ -189,14 +190,14 @@ test('journeys – station to POI', async (t) => {
|
||||||
latitude: 52.543333,
|
latitude: 52.543333,
|
||||||
longitude: 13.351686
|
longitude: 13.351686
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(spichernstr, atze, {
|
const res = await client.journeys(spichernstr, atze, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: spichernstr,
|
fromId: spichernstr,
|
||||||
to: atze
|
to: atze
|
||||||
|
@ -207,7 +208,7 @@ test('journeys – station to POI', async (t) => {
|
||||||
test('journeys: via works – with detour', async (t) => {
|
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 journeys = await client.journeys(westhafen, wedding, {
|
const res = await client.journeys(westhafen, wedding, {
|
||||||
via: württembergallee,
|
via: württembergallee,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -216,7 +217,7 @@ test('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [württembergallee]
|
detourIds: [württembergallee]
|
||||||
})
|
})
|
||||||
|
|
20
test/vbn.js
20
test/vbn.js
|
@ -40,7 +40,7 @@ const bremenHbf = '8000050'
|
||||||
const bremerhavenHbf = '8000051'
|
const bremerhavenHbf = '8000051'
|
||||||
|
|
||||||
test.only('journeys – Bremen Hbf to Bremerhaven Hbf', async (t) => {
|
test.only('journeys – Bremen Hbf to Bremerhaven Hbf', async (t) => {
|
||||||
const journeys = await client.journeys(bremenHbf, bremerhavenHbf, {
|
const res = await client.journeys(bremenHbf, bremerhavenHbf, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when,
|
departure: when,
|
||||||
stopovers: true
|
stopovers: true
|
||||||
|
@ -48,7 +48,7 @@ test.only('journeys – Bremen Hbf to Bremerhaven Hbf', async (t) => {
|
||||||
|
|
||||||
await testJourneysStationToStation({
|
await testJourneysStationToStation({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: bremenHbf,
|
fromId: bremenHbf,
|
||||||
toId: bremerhavenHbf
|
toId: bremerhavenHbf
|
||||||
|
@ -78,14 +78,14 @@ test.skip('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
|
||||||
longitude: 11.422332
|
longitude: 11.422332
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeys = await client.journeys(bremenHbf, sternStr, {
|
const res = await client.journeys(bremenHbf, sternStr, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToAddress({
|
await testJourneysStationToAddress({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: bremenHbf,
|
fromId: bremenHbf,
|
||||||
to: sternStr
|
to: sternStr
|
||||||
|
@ -101,14 +101,14 @@ test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
|
||||||
latitude: 52.127601,
|
latitude: 52.127601,
|
||||||
longitude: 11.636437
|
longitude: 11.636437
|
||||||
}
|
}
|
||||||
const journeys = await client.journeys(bremenHbf, kloster, {
|
const res = await client.journeys(bremenHbf, kloster, {
|
||||||
results: 3,
|
results: 3,
|
||||||
departure: when
|
departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
await testJourneysStationToPoi({
|
await testJourneysStationToPoi({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
fromId: bremenHbf,
|
fromId: bremenHbf,
|
||||||
to: kloster
|
to: kloster
|
||||||
|
@ -120,7 +120,7 @@ test.skip('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.
|
||||||
const journeys = await client.journeys(hasselbachplatzSternstrasse, stendal, {
|
const res = await client.journeys(hasselbachplatzSternstrasse, stendal, {
|
||||||
via: dessau,
|
via: dessau,
|
||||||
results: 1,
|
results: 1,
|
||||||
departure: when,
|
departure: when,
|
||||||
|
@ -129,7 +129,7 @@ test.skip('journeys: via works – with detour', async (t) => {
|
||||||
|
|
||||||
await testJourneysWithDetour({
|
await testJourneysWithDetour({
|
||||||
test: t,
|
test: t,
|
||||||
journeys,
|
res,
|
||||||
validate,
|
validate,
|
||||||
detourIds: [dessau]
|
detourIds: [dessau]
|
||||||
})
|
})
|
||||||
|
@ -165,11 +165,11 @@ test.skip('refreshJourney', async (t) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test.skip('trip details', async (t) => {
|
test.skip('trip details', async (t) => {
|
||||||
const journeys = await client.journeys(bremenHbf, bremerhavenHbf, {
|
const res = await client.journeys(bremenHbf, bremerhavenHbf, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
|
||||||
const p = journeys[0].legs[0]
|
const p = res.journeys[0].legs[0]
|
||||||
t.ok(p.tripId, 'precondition failed')
|
t.ok(p.tripId, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||||
|
|
Loading…
Add table
Reference in a new issue