diff --git a/docs/journeys.md b/docs/journeys.md index febbe95f..12b4436c 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -22,6 +22,7 @@ { type: 'location', id: '123', + poi: true, name: 'foo restaurant', latitude: 1.23, longitude: 3.21 diff --git a/docs/locations.md b/docs/locations.md index 8f0f7508..1b385762 100644 --- a/docs/locations.md +++ b/docs/locations.md @@ -55,12 +55,14 @@ The response may look like this: }, { // point of interest type: 'location', id: '900980709', + poi: true, name: 'Berlin, Holiday Inn Centre Alexanderplatz****', latitude: 52.523549, longitude: 13.418441 }, { // point of interest type: 'location', id: '900980176', + poi: true, name: 'Berlin, Hotel Agon am Alexanderplatz', latitude: 52.524556, longitude: 13.420266 diff --git a/test/bvg.js b/test/bvg.js index 1813c62f..af745a4c 100644 --- a/test/bvg.js +++ b/test/bvg.js @@ -206,6 +206,7 @@ test('journeys – station to POI', async (t) => { const atze = { type: 'location', id: '900980720', + poi: true, name: 'Berlin, Atze Musiktheater für Kinder', latitude: 52.543333, longitude: 13.351686 @@ -356,7 +357,7 @@ test('locations', async (t) => { t.ok(locations.length <= 20) 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.end() diff --git a/test/cmta.js b/test/cmta.js index 2087262c..bb4df066 100644 --- a/test/cmta.js +++ b/test/cmta.js @@ -99,6 +99,7 @@ test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => { const wholeFoodsMarket = { type: 'location', id: '9845477', + poi: true, name: 'Whole Foods Market - N Lamar Blvd', latitude: 30.270653, longitude: -97.753564 @@ -217,7 +218,7 @@ test('locations named "Capitol"', async (t) => { t.ok(locations.length <= 10) 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) => { return l.station && l.station.id === capitol591 || l.id === capitol591 })) diff --git a/test/db.js b/test/db.js index fb917082..9afc6f44 100644 --- a/test/db.js +++ b/test/db.js @@ -149,6 +149,7 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => { const atze = { type: 'location', id: '991598902', + poi: true, name: 'ATZE Musiktheater', latitude: 52.542417, longitude: 13.350437 diff --git a/test/insa.js b/test/insa.js index 42d78697..5866c2f6 100644 --- a/test/insa.js +++ b/test/insa.js @@ -104,6 +104,7 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => { const kloster = { type: 'location', id: '970012223', + poi: true, name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)', latitude: 52.127601, longitude: 11.636437 @@ -242,7 +243,7 @@ test('locations named Magdeburg', async (t) => { t.ok(locations.length <= 20) 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) => { return l.station && l.station.id === nordpark || l.id === nordpark })) diff --git a/test/lib/validators.js b/test/lib/validators.js index 44293482..4745a42b 100644 --- a/test/lib/validators.js +++ b/test/lib/validators.js @@ -47,6 +47,8 @@ const validatePoi = (val, poi, name = 'location') => { defaultValidators.location(val, poi, name) val.ref(val, poi.id, name + '.id') // 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') } @@ -60,7 +62,7 @@ const validateLocation = (val, loc, name = 'location') => { a.ok(isObj(loc), name + ' must be an object') if (loc.type === 'stop') val.stop(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)) { validateAddress(val, loc, name) } else defaultValidators.location(val, loc, name) diff --git a/test/nahsh.js b/test/nahsh.js index 1251b2f2..3b01f9fe 100644 --- a/test/nahsh.js +++ b/test/nahsh.js @@ -139,6 +139,7 @@ test('Kiel Hbf to Holstentor', async (t) => { const holstentor = { type: 'location', id: '970003118', + poi: true, name: 'Hansestadt Lübeck, Holstentor (Denkmal)', latitude: 53.866321, longitude: 10.679976 @@ -313,7 +314,7 @@ test('locations named "Kiel Rathaus"', async (t) => { t.ok(locations.length <= 15) 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.end() diff --git a/test/oebb.js b/test/oebb.js index dbc71b23..cdd31be1 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -128,10 +128,11 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', async (t) => { test('Salzburg Hbf to Albertina', async (t) => { const albertina = { type: 'location', - id: '975900003', - name: 'Albertina', - latitude: 48.204699, - longitude: 16.368404 + id: '975900003', + poi: true, + name: 'Albertina', + latitude: 48.204699, + longitude: 16.368404 } const res = await client.journeys(salzburgHbf, albertina, { results: 3, departure: when @@ -334,7 +335,7 @@ test('locations named Salzburg', async (t) => { t.ok(locations.length <= 20) 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) => { return s.station && s.station.id === salzburgHbf || s.id === salzburgHbf })) diff --git a/test/saarfahrplan.js b/test/saarfahrplan.js index aeca72e4..a6db9af8 100644 --- a/test/saarfahrplan.js +++ b/test/saarfahrplan.js @@ -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) => { const schlossberghoehlen = { type: 'location', - latitude: 49.32071, - longitude: 7.343764, + id: '9000185', + poi: true, name: 'Homburg, Schlossberghöhlen', - id: '9000185' + latitude: 49.32071, + longitude: 7.343764 } const res = await client.journeys(saarbrueckenHbf, schlossberghoehlen, { results: 3, departure: when @@ -293,7 +294,7 @@ test('locations named Saarbrücken', async (t) => { t.ok(locations.length <= 20) 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) => { return s.station && s.station.id === saarbrueckenHbf || s.id === saarbrueckenHbf })) diff --git a/test/sbahn-muenchen.js b/test/sbahn-muenchen.js index 4d964e6d..9c11376d 100644 --- a/test/sbahn-muenchen.js +++ b/test/sbahn-muenchen.js @@ -113,6 +113,7 @@ test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => { const hofbraeuhaus = { type: 'location', id: '970006201', + poi: true, name: 'München, Hofbräuhaus', latitude: 48.137739, longitude: 11.579823 @@ -233,7 +234,7 @@ test('locations named "Nationaltheater"', async (t) => { t.ok(locations.length <= 10) 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) => { return l.station && l.station.id === nationaltheater || l.id === nationaltheater })) diff --git a/test/vbb.js b/test/vbb.js index f4374703..4a525da2 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -186,6 +186,7 @@ test('journeys – station to POI', async (t) => { const atze = { type: 'location', id: '900980720', + poi: true, name: 'Berlin, Atze Musiktheater für Kinder', latitude: 52.543333, longitude: 13.351686 @@ -337,7 +338,7 @@ test('locations', async (t) => { t.ok(locations.length <= 20) 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.end() diff --git a/test/vbn.js b/test/vbn.js index 5c7bbb88..7e1378d4 100644 --- a/test/vbn.js +++ b/test/vbn.js @@ -97,6 +97,7 @@ test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => { const kloster = { type: 'location', id: '970012223', + poi: true, name: 'Magdeburg, Kloster Unser Lieben Frauen (Denkmal)', latitude: 52.127601, longitude: 11.636437 @@ -235,7 +236,7 @@ test.skip('locations named Magdeburg', async (t) => { t.ok(locations.length <= 20) 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) => { return l.station && l.station.id === bremenHbf || l.id === bremenHbf }))