Skip to content

Commit

Permalink
adapt docs & tests to eb3ffba 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Feb 28, 2019
1 parent eb3ffba commit eab850e
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/journeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{
type: 'location',
id: '123',
poi: true,
name: 'foo restaurant',
latitude: 1.23,
longitude: 3.21
Expand Down
2 changes: 2 additions & 0 deletions docs/locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/bvg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/cmta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down
1 change: 1 addition & 0 deletions test/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/insa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down
4 changes: 3 additions & 1 deletion test/lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion test/nahsh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 6 additions & 5 deletions test/oebb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down
9 changes: 5 additions & 4 deletions test/saarfahrplan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down
3 changes: 2 additions & 1 deletion test/sbahn-muenchen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down
3 changes: 2 additions & 1 deletion test/vbb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/vbn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
Expand Down

0 comments on commit eab850e

Please sign in to comment.