mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
adapt docs & tests to eb3ffba
📝
This commit is contained in:
parent
eb3ffba4fc
commit
eab850e058
13 changed files with 32 additions and 17 deletions
|
@ -22,6 +22,7 @@
|
||||||
{
|
{
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '123',
|
id: '123',
|
||||||
|
poi: true,
|
||||||
name: 'foo restaurant',
|
name: 'foo restaurant',
|
||||||
latitude: 1.23,
|
latitude: 1.23,
|
||||||
longitude: 3.21
|
longitude: 3.21
|
||||||
|
|
|
@ -55,12 +55,14 @@ The response may look like this:
|
||||||
}, { // point of interest
|
}, { // point of interest
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '900980709',
|
id: '900980709',
|
||||||
|
poi: true,
|
||||||
name: 'Berlin, Holiday Inn Centre Alexanderplatz****',
|
name: 'Berlin, Holiday Inn Centre Alexanderplatz****',
|
||||||
latitude: 52.523549,
|
latitude: 52.523549,
|
||||||
longitude: 13.418441
|
longitude: 13.418441
|
||||||
}, { // point of interest
|
}, { // point of interest
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '900980176',
|
id: '900980176',
|
||||||
|
poi: true,
|
||||||
name: 'Berlin, Hotel Agon am Alexanderplatz',
|
name: 'Berlin, Hotel Agon am Alexanderplatz',
|
||||||
latitude: 52.524556,
|
latitude: 52.524556,
|
||||||
longitude: 13.420266
|
longitude: 13.420266
|
||||||
|
|
|
@ -206,6 +206,7 @@ test('journeys – station to POI', async (t) => {
|
||||||
const atze = {
|
const atze = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '900980720',
|
id: '900980720',
|
||||||
|
poi: true,
|
||||||
name: 'Berlin, Atze Musiktheater für Kinder',
|
name: 'Berlin, Atze Musiktheater für Kinder',
|
||||||
latitude: 52.543333,
|
latitude: 52.543333,
|
||||||
longitude: 13.351686
|
longitude: 13.351686
|
||||||
|
@ -356,7 +357,7 @@ test('locations', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.find(s => !s.name && s.address)) // addresses
|
t.ok(locations.find(s => !s.name && s.address)) // addresses
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
|
|
@ -99,6 +99,7 @@ test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
|
||||||
const wholeFoodsMarket = {
|
const wholeFoodsMarket = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '9845477',
|
id: '9845477',
|
||||||
|
poi: true,
|
||||||
name: 'Whole Foods Market - N Lamar Blvd',
|
name: 'Whole Foods Market - N Lamar Blvd',
|
||||||
latitude: 30.270653,
|
latitude: 30.270653,
|
||||||
longitude: -97.753564
|
longitude: -97.753564
|
||||||
|
@ -217,7 +218,7 @@ test('locations named "Capitol"', async (t) => {
|
||||||
t.ok(locations.length <= 10)
|
t.ok(locations.length <= 10)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((l) => {
|
t.ok(locations.some((l) => {
|
||||||
return l.station && l.station.id === capitol591 || l.id === capitol591
|
return l.station && l.station.id === capitol591 || l.id === capitol591
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -149,6 +149,7 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
|
||||||
const atze = {
|
const atze = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '991598902',
|
id: '991598902',
|
||||||
|
poi: true,
|
||||||
name: 'ATZE Musiktheater',
|
name: 'ATZE Musiktheater',
|
||||||
latitude: 52.542417,
|
latitude: 52.542417,
|
||||||
longitude: 13.350437
|
longitude: 13.350437
|
||||||
|
|
|
@ -104,6 +104,7 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
|
||||||
const kloster = {
|
const kloster = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '970012223',
|
id: '970012223',
|
||||||
|
poi: true,
|
||||||
name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)',
|
name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)',
|
||||||
latitude: 52.127601,
|
latitude: 52.127601,
|
||||||
longitude: 11.636437
|
longitude: 11.636437
|
||||||
|
@ -242,7 +243,7 @@ test('locations named Magdeburg', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((l) => {
|
t.ok(locations.some((l) => {
|
||||||
return l.station && l.station.id === nordpark || l.id === nordpark
|
return l.station && l.station.id === nordpark || l.id === nordpark
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -47,6 +47,8 @@ const validatePoi = (val, poi, name = 'location') => {
|
||||||
defaultValidators.location(val, poi, name)
|
defaultValidators.location(val, poi, name)
|
||||||
val.ref(val, poi.id, name + '.id')
|
val.ref(val, poi.id, name + '.id')
|
||||||
// todo: check if s.id has leading zeros
|
// todo: check if s.id has leading zeros
|
||||||
|
a.strictEqual(poi.poi, true, name + '.poi must be true')
|
||||||
|
a.strictEqual(typeof poi.name, 'string', name + '.name must be a string')
|
||||||
a.ok(poi.name, name + '.name must not be empty')
|
a.ok(poi.name, name + '.name must not be empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ const validateLocation = (val, loc, name = 'location') => {
|
||||||
a.ok(isObj(loc), name + ' must be an object')
|
a.ok(isObj(loc), name + ' must be an object')
|
||||||
if (loc.type === 'stop') val.stop(val, loc, name)
|
if (loc.type === 'stop') val.stop(val, loc, name)
|
||||||
else if (loc.type === 'station') val.station(val, loc, name)
|
else if (loc.type === 'station') val.station(val, loc, name)
|
||||||
else if ('id' in loc) validatePoi(val, loc, name)
|
else if (loc.poi) validatePoi(val, loc, name)
|
||||||
else if (!('name' in loc) && ('address' in loc)) {
|
else if (!('name' in loc) && ('address' in loc)) {
|
||||||
validateAddress(val, loc, name)
|
validateAddress(val, loc, name)
|
||||||
} else defaultValidators.location(val, loc, name)
|
} else defaultValidators.location(val, loc, name)
|
||||||
|
|
|
@ -139,6 +139,7 @@ test('Kiel Hbf to Holstentor', async (t) => {
|
||||||
const holstentor = {
|
const holstentor = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '970003118',
|
id: '970003118',
|
||||||
|
poi: true,
|
||||||
name: 'Hansestadt Lübeck, Holstentor (Denkmal)',
|
name: 'Hansestadt Lübeck, Holstentor (Denkmal)',
|
||||||
latitude: 53.866321,
|
latitude: 53.866321,
|
||||||
longitude: 10.679976
|
longitude: 10.679976
|
||||||
|
@ -313,7 +314,7 @@ test('locations named "Kiel Rathaus"', async (t) => {
|
||||||
t.ok(locations.length <= 15)
|
t.ok(locations.length <= 15)
|
||||||
|
|
||||||
t.ok(locations.find(l => l.type === 'stop' || l.type === 'station'))
|
t.ok(locations.find(l => l.type === 'stop' || l.type === 'station'))
|
||||||
t.ok(locations.find(l => l.id && l.name)) // POIs
|
t.ok(locations.find(l => l.poi)) // POIs
|
||||||
t.ok(locations.some(l => l.station && l.station.id === kielRathaus || l.id === kielRathaus))
|
t.ok(locations.some(l => l.station && l.station.id === kielRathaus || l.id === kielRathaus))
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
|
|
@ -129,6 +129,7 @@ test('Salzburg Hbf to Albertina', async (t) => {
|
||||||
const albertina = {
|
const albertina = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '975900003',
|
id: '975900003',
|
||||||
|
poi: true,
|
||||||
name: 'Albertina',
|
name: 'Albertina',
|
||||||
latitude: 48.204699,
|
latitude: 48.204699,
|
||||||
longitude: 16.368404
|
longitude: 16.368404
|
||||||
|
@ -334,7 +335,7 @@ test('locations named Salzburg', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((s) => {
|
t.ok(locations.some((s) => {
|
||||||
return s.station && s.station.id === salzburgHbf || s.id === salzburgHbf
|
return s.station && s.station.id === salzburgHbf || s.id === salzburgHbf
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -102,10 +102,11 @@ test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
|
||||||
test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
|
test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
|
||||||
const schlossberghoehlen = {
|
const schlossberghoehlen = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
latitude: 49.32071,
|
id: '9000185',
|
||||||
longitude: 7.343764,
|
poi: true,
|
||||||
name: 'Homburg, Schlossberghöhlen',
|
name: 'Homburg, Schlossberghöhlen',
|
||||||
id: '9000185'
|
latitude: 49.32071,
|
||||||
|
longitude: 7.343764
|
||||||
}
|
}
|
||||||
const res = await client.journeys(saarbrueckenHbf, schlossberghoehlen, {
|
const res = await client.journeys(saarbrueckenHbf, schlossberghoehlen, {
|
||||||
results: 3, departure: when
|
results: 3, departure: when
|
||||||
|
@ -293,7 +294,7 @@ test('locations named Saarbrücken', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((s) => {
|
t.ok(locations.some((s) => {
|
||||||
return s.station && s.station.id === saarbrueckenHbf || s.id === saarbrueckenHbf
|
return s.station && s.station.id === saarbrueckenHbf || s.id === saarbrueckenHbf
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -113,6 +113,7 @@ test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
|
||||||
const hofbraeuhaus = {
|
const hofbraeuhaus = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '970006201',
|
id: '970006201',
|
||||||
|
poi: true,
|
||||||
name: 'München, Hofbräuhaus',
|
name: 'München, Hofbräuhaus',
|
||||||
latitude: 48.137739,
|
latitude: 48.137739,
|
||||||
longitude: 11.579823
|
longitude: 11.579823
|
||||||
|
@ -233,7 +234,7 @@ test('locations named "Nationaltheater"', async (t) => {
|
||||||
t.ok(locations.length <= 10)
|
t.ok(locations.length <= 10)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((l) => {
|
t.ok(locations.some((l) => {
|
||||||
return l.station && l.station.id === nationaltheater || l.id === nationaltheater
|
return l.station && l.station.id === nationaltheater || l.id === nationaltheater
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -186,6 +186,7 @@ test('journeys – station to POI', async (t) => {
|
||||||
const atze = {
|
const atze = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '900980720',
|
id: '900980720',
|
||||||
|
poi: true,
|
||||||
name: 'Berlin, Atze Musiktheater für Kinder',
|
name: 'Berlin, Atze Musiktheater für Kinder',
|
||||||
latitude: 52.543333,
|
latitude: 52.543333,
|
||||||
longitude: 13.351686
|
longitude: 13.351686
|
||||||
|
@ -337,7 +338,7 @@ test('locations', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.find(s => !s.name && s.address)) // addresses
|
t.ok(locations.find(s => !s.name && s.address)) // addresses
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
|
|
|
@ -97,6 +97,7 @@ test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
|
||||||
const kloster = {
|
const kloster = {
|
||||||
type: 'location',
|
type: 'location',
|
||||||
id: '970012223',
|
id: '970012223',
|
||||||
|
poi: true,
|
||||||
name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)',
|
name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)',
|
||||||
latitude: 52.127601,
|
latitude: 52.127601,
|
||||||
longitude: 11.636437
|
longitude: 11.636437
|
||||||
|
@ -235,7 +236,7 @@ test.skip('locations named Magdeburg', async (t) => {
|
||||||
t.ok(locations.length <= 20)
|
t.ok(locations.length <= 20)
|
||||||
|
|
||||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||||
t.ok(locations.find(s => s.id && s.name)) // POIs
|
t.ok(locations.find(s => s.poi)) // POIs
|
||||||
t.ok(locations.some((l) => {
|
t.ok(locations.some((l) => {
|
||||||
return l.station && l.station.id === bremenHbf || l.id === bremenHbf
|
return l.station && l.station.id === bremenHbf || l.id === bremenHbf
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue