mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	tests: co/yield -> async/await
This commit is contained in:
		
							parent
							
								
									bf3c4c58a1
								
							
						
					
					
						commit
						59584a3402
					
				
					 23 changed files with 557 additions and 624 deletions
				
			
		
							
								
								
									
										136
									
								
								test/bvg.js
									
										
									
									
									
								
							
							
						
						
									
										136
									
								
								test/bvg.js
									
										
									
									
									
								
							| 
						 | 
					@ -9,7 +9,6 @@ const tapePromise = require('tape-promise').default
 | 
				
			||||||
const tape = require('tape')
 | 
					const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const bvgProfile = require('../p/bvg')
 | 
					const bvgProfile = require('../p/bvg')
 | 
				
			||||||
const products = require('../p/bvg/products')
 | 
					const products = require('../p/bvg/products')
 | 
				
			||||||
| 
						 | 
					@ -66,14 +65,14 @@ const jannowitzbrücke = '900000100004'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const hour = 60 * 60 * 1000
 | 
					const hour = 60 * 60 * 1000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) {
 | 
					test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, bismarckstr, {
 | 
						const journeys = await client.journeys(spichernstr, bismarckstr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -83,10 +82,10 @@ test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) {
 | 
				
			||||||
	// todo: find a journey where there ticket info is always available
 | 
						// todo: find a journey where there ticket info is always available
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – only subway', co(function* (t) {
 | 
					test('journeys – only subway', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, bismarckstr, {
 | 
						const journeys = await client.journeys(spichernstr, bismarckstr, {
 | 
				
			||||||
		results: 20,
 | 
							results: 20,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		products: {
 | 
							products: {
 | 
				
			||||||
| 
						 | 
					@ -117,7 +116,7 @@ test('journeys – only subway', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – fails with no product', (t) => {
 | 
					test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	journeysFailsWithNoProduct({
 | 
						journeysFailsWithNoProduct({
 | 
				
			||||||
| 
						 | 
					@ -131,8 +130,8 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys', co(function* (t) {
 | 
					test('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -142,20 +141,19 @@ test('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys – leg cycle & alternatives', co(function* (t) {
 | 
					test.skip('journeys – leg cycle & alternatives', async (t) => {
 | 
				
			||||||
	yield testLegCycleAlternatives({
 | 
						await testLegCycleAlternatives({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		fromId: tiergarten,
 | 
							fromId: tiergarten,
 | 
				
			||||||
		toId: jannowitzbrücke
 | 
							toId: jannowitzbrücke
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
						await testRefreshJourney({
 | 
				
			||||||
	yield testRefreshJourney({
 | 
					 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -165,35 +163,35 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, amrumerStr, {
 | 
						const journeys = await client.journeys(spichernstr, amrumerStr, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – station to address', co(function* (t) {
 | 
					test('journeys – station to address', async (t) => {
 | 
				
			||||||
	const torfstr = {
 | 
						const torfstr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
							address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
				
			||||||
		latitude: 52.541797,
 | 
							latitude: 52.541797,
 | 
				
			||||||
		longitude: 13.350042
 | 
							longitude: 13.350042
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, torfstr, {
 | 
						const journeys = await client.journeys(spichernstr, torfstr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -201,9 +199,9 @@ test('journeys – station to address', co(function* (t) {
 | 
				
			||||||
		to: torfstr
 | 
							to: torfstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – station to POI', co(function* (t) {
 | 
					test('journeys – station to POI', async (t) => {
 | 
				
			||||||
	const atze = {
 | 
						const atze = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '900980720',
 | 
							id: '900980720',
 | 
				
			||||||
| 
						 | 
					@ -211,12 +209,12 @@ test('journeys – station to POI', co(function* (t) {
 | 
				
			||||||
		latitude: 52.543333,
 | 
							latitude: 52.543333,
 | 
				
			||||||
		longitude: 13.351686
 | 
							longitude: 13.351686
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, atze, {
 | 
						const journeys = await client.journeys(spichernstr, atze, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -224,46 +222,46 @@ test('journeys – station to POI', co(function* (t) {
 | 
				
			||||||
		to: atze
 | 
							to: atze
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – with detour', co(function* (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 = yield client.journeys(westhafen, wedding, {
 | 
						const journeys = await client.journeys(westhafen, wedding, {
 | 
				
			||||||
		via: württembergallee,
 | 
							via: württembergallee,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [württembergallee]
 | 
							detourIds: [württembergallee]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: without detour test
 | 
					// todo: without detour test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures', co(function* (t) {
 | 
					test('departures', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(spichernstr, {
 | 
						const departures = await client.departures(spichernstr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: spichernstr
 | 
							id: spichernstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: spichernstr,
 | 
							id: spichernstr,
 | 
				
			||||||
		name: 'U Spichernstr',
 | 
							name: 'U Spichernstr',
 | 
				
			||||||
| 
						 | 
					@ -276,10 +274,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Spichernstr. in direction of Westhafen', co(function* (t) {
 | 
					test('departures at Spichernstr. in direction of Westhafen', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -289,17 +287,17 @@ test('departures at Spichernstr. in direction of Westhafen', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at 7-digit station', co(function* (t) {
 | 
					test('departures at 7-digit station', async (t) => {
 | 
				
			||||||
	const eisenach = '8010097' // see derhuerst/vbb-hafas#22
 | 
						const eisenach = '8010097' // see derhuerst/vbb-hafas#22
 | 
				
			||||||
	yield client.departures(eisenach, {when})
 | 
						await client.departures(eisenach, {when})
 | 
				
			||||||
	t.pass('did not fail')
 | 
						t.pass('did not fail')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures without related stations', co(function* (t) {
 | 
					test('departures without related stations', async (t) => {
 | 
				
			||||||
	yield testDeparturesWithoutRelatedStations({
 | 
						await testDeparturesWithoutRelatedStations({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		id: '900000024101', // Charlottenburg
 | 
							id: '900000024101', // Charlottenburg
 | 
				
			||||||
| 
						 | 
					@ -308,28 +306,28 @@ test('departures without related stations', co(function* (t) {
 | 
				
			||||||
		linesOfRelatedStations: ['U7']
 | 
							linesOfRelatedStations: ['U7']
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals', co(function* (t) {
 | 
					test('arrivals', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(spichernstr, {
 | 
						const arrivals = await client.arrivals(spichernstr, {
 | 
				
			||||||
		duration: 5, when
 | 
							duration: 5, when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: spichernstr
 | 
							id: spichernstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby', co(function* (t) {
 | 
					test('nearby', async (t) => {
 | 
				
			||||||
	const berlinerStr = '900000044201'
 | 
						const berlinerStr = '900000044201'
 | 
				
			||||||
	const landhausstr = '900000043252'
 | 
						const landhausstr = '900000043252'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Berliner Str./Bundesallee
 | 
						// Berliner Str./Bundesallee
 | 
				
			||||||
	const nearby = yield client.nearby({
 | 
						const nearby = await client.nearby({
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 52.4873452,
 | 
							latitude: 52.4873452,
 | 
				
			||||||
		longitude: 13.3310411
 | 
							longitude: 13.3310411
 | 
				
			||||||
| 
						 | 
					@ -348,10 +346,10 @@ test('nearby', co(function* (t) {
 | 
				
			||||||
	t.ok(nearby[1].distance < 200)
 | 
						t.ok(nearby[1].distance < 200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations', co(function* (t) {
 | 
					test('locations', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Alexanderplatz', {results: 20})
 | 
						const locations = await client.locations('Alexanderplatz', {results: 20})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, locations, 'locations', 'locations')
 | 
						validate(t, locations, 'locations', 'locations')
 | 
				
			||||||
	t.ok(locations.length <= 20)
 | 
						t.ok(locations.length <= 20)
 | 
				
			||||||
| 
						 | 
					@ -361,19 +359,19 @@ test('locations', co(function* (t) {
 | 
				
			||||||
	t.ok(locations.find(s => !s.name && s.address)) // addresses
 | 
						t.ok(locations.find(s => !s.name && s.address)) // addresses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const s = yield client.station(spichernstr)
 | 
						const s = await client.station(spichernstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, spichernstr)
 | 
						t.equal(s.id, spichernstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 52.52411,
 | 
							north: 52.52411,
 | 
				
			||||||
		west: 13.41002,
 | 
							west: 13.41002,
 | 
				
			||||||
		south: 52.51942,
 | 
							south: 52.51942,
 | 
				
			||||||
| 
						 | 
					@ -384,9 +382,9 @@ test('radar', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	const torfstr17 = {
 | 
						const torfstr17 = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
							address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
				
			||||||
| 
						 | 
					@ -394,7 +392,7 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		longitude: 13.350042
 | 
							longitude: 13.350042
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: torfstr17,
 | 
							address: torfstr17,
 | 
				
			||||||
| 
						 | 
					@ -403,4 +401,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										91
									
								
								test/cmta.js
									
										
									
									
									
								
							
							
						
						
									
										91
									
								
								test/cmta.js
									
										
									
									
									
								
							| 
						 | 
					@ -5,7 +5,6 @@ const tapePromise = require('tape-promise').default
 | 
				
			||||||
const tape = require('tape')
 | 
					const tape = require('tape')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const cmtaProfile = require('../p/cmta')
 | 
					const cmtaProfile = require('../p/cmta')
 | 
				
			||||||
const products = require('../p/cmta/products')
 | 
					const products = require('../p/cmta/products')
 | 
				
			||||||
| 
						 | 
					@ -42,14 +41,14 @@ const broadieOaks = '2370'
 | 
				
			||||||
const domain = '5919'
 | 
					const domain = '5919'
 | 
				
			||||||
const capitol591 = '591'
 | 
					const capitol591 = '591'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Broadie Oaks to Domain', co(function* (t) {
 | 
					test('journeys – Broadie Oaks to Domain', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(broadieOaks, domain, {
 | 
						const journeys = await client.journeys(broadieOaks, domain, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -57,7 +56,7 @@ test('journeys – Broadie Oaks to Domain', co(function* (t) {
 | 
				
			||||||
		toId: domain
 | 
							toId: domain
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +72,7 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Domain to 1104 Elm Street, Austin, TX 78703', co(function*(t) {
 | 
					test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => {
 | 
				
			||||||
	const someAddress = {
 | 
						const someAddress = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: '1104 ELM ST, Austin, TX 78703',
 | 
							address: '1104 ELM ST, Austin, TX 78703',
 | 
				
			||||||
| 
						 | 
					@ -81,12 +80,12 @@ test('Domain to 1104 Elm Street, Austin, TX 78703', co(function*(t) {
 | 
				
			||||||
		longitude: -97.758292
 | 
							longitude: -97.758292
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const journeys = yield client.journeys(domain, someAddress, {
 | 
						const journeys = await client.journeys(domain, someAddress, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -94,9 +93,9 @@ test('Domain to 1104 Elm Street, Austin, TX 78703', co(function*(t) {
 | 
				
			||||||
		to: someAddress
 | 
							to: someAddress
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Domain to Whole Foods Market - North Lamar Blvd', co(function*(t) {
 | 
					test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
 | 
				
			||||||
	const wholeFoodsMarket = {
 | 
						const wholeFoodsMarket = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '9845477',
 | 
							id: '9845477',
 | 
				
			||||||
| 
						 | 
					@ -104,12 +103,12 @@ test('Domain to Whole Foods Market - North Lamar Blvd', co(function*(t) {
 | 
				
			||||||
		latitude: 30.270653,
 | 
							latitude: 30.270653,
 | 
				
			||||||
		longitude: -97.753564
 | 
							longitude: -97.753564
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(domain, wholeFoodsMarket, {
 | 
						const journeys = await client.journeys(domain, wholeFoodsMarket, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -117,13 +116,13 @@ test('Domain to Whole Foods Market - North Lamar Blvd', co(function*(t) {
 | 
				
			||||||
		to: wholeFoodsMarket
 | 
							to: wholeFoodsMarket
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: via works – with detour
 | 
					// todo: via works – with detour
 | 
				
			||||||
// todo: without detour
 | 
					// todo: without detour
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys', co(function* (t) {
 | 
					test('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -133,10 +132,10 @@ test('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -146,39 +145,39 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(broadieOaks, domain, {
 | 
						const journeys = await client.journeys(broadieOaks, domain, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Broadie Oaks', co(function*(t) {
 | 
					test('departures at Broadie Oaks', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(broadieOaks, {
 | 
						const departures = await client.departures(broadieOaks, {
 | 
				
			||||||
		duration: 10, when,
 | 
							duration: 10, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: broadieOaks
 | 
							id: broadieOaks
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: broadieOaks,
 | 
							id: broadieOaks,
 | 
				
			||||||
		name: 'Magdeburg Hbf',
 | 
							name: 'Magdeburg Hbf',
 | 
				
			||||||
| 
						 | 
					@ -191,26 +190,26 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals at Broadie Oaks', co(function*(t) {
 | 
					test('arrivals at Broadie Oaks', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(broadieOaks, {
 | 
						const arrivals = await client.arrivals(broadieOaks, {
 | 
				
			||||||
		duration: 10, when
 | 
							duration: 10, when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: broadieOaks
 | 
							id: broadieOaks
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: nearby
 | 
					// todo: nearby
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named "Capitol"', co(function*(t) {
 | 
					test('locations named "Capitol"', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Capitol', {
 | 
						const locations = await client.locations('Capitol', {
 | 
				
			||||||
		results: 10
 | 
							results: 10
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -224,19 +223,19 @@ test('locations named "Capitol"', co(function*(t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station Domain', co(function* (t) {
 | 
					test('station Domain', async (t) => {
 | 
				
			||||||
	const s = yield client.station(domain)
 | 
						const s = await client.station(domain)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, domain)
 | 
						t.equal(s.id, domain)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 30.240877,
 | 
							north: 30.240877,
 | 
				
			||||||
		west: -97.804588,
 | 
							west: -97.804588,
 | 
				
			||||||
		south: 30.225378,
 | 
							south: 30.225378,
 | 
				
			||||||
| 
						 | 
					@ -247,10 +246,10 @@ test('radar', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: {
 | 
							address: {
 | 
				
			||||||
| 
						 | 
					@ -264,4 +263,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										123
									
								
								test/db.js
									
										
									
									
									
								
							
							
						
						
									
										123
									
								
								test/db.js
									
										
									
									
									
								
							| 
						 | 
					@ -7,7 +7,6 @@ const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const dbProfile = require('../p/db')
 | 
					const dbProfile = require('../p/db')
 | 
				
			||||||
const products = require('../p/db/products')
 | 
					const products = require('../p/db/products')
 | 
				
			||||||
| 
						 | 
					@ -88,14 +87,14 @@ const blnTiergarten = '8089091'
 | 
				
			||||||
const blnJannowitzbrücke = '8089019'
 | 
					const blnJannowitzbrücke = '8089019'
 | 
				
			||||||
const potsdamHbf = '8012666'
 | 
					const potsdamHbf = '8012666'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Berlin Schwedter Str. to München Hbf', co(function* (t) {
 | 
					test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(blnSchwedterStr, münchenHbf, {
 | 
						const journeys = await client.journeys(blnSchwedterStr, münchenHbf, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -108,7 +107,7 @@ test('journeys – Berlin Schwedter Str. to München Hbf', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -124,19 +123,19 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Berlin Schwedter Str. to Torfstraße 17', co(function* (t) {
 | 
					test('Berlin Schwedter Str. to Torfstraße 17', async (t) => {
 | 
				
			||||||
	const torfstr = {
 | 
						const torfstr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Torfstraße 17',
 | 
							address: 'Torfstraße 17',
 | 
				
			||||||
		latitude: 52.5416823,
 | 
							latitude: 52.5416823,
 | 
				
			||||||
		longitude: 13.3491223
 | 
							longitude: 13.3491223
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(blnSchwedterStr, torfstr, {
 | 
						const journeys = await client.journeys(blnSchwedterStr, torfstr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -144,9 +143,9 @@ test('Berlin Schwedter Str. to Torfstraße 17', co(function* (t) {
 | 
				
			||||||
		to: torfstr
 | 
							to: torfstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Berlin Schwedter Str. to ATZE Musiktheater', co(function* (t) {
 | 
					test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
 | 
				
			||||||
	const atze = {
 | 
						const atze = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '991598902',
 | 
							id: '991598902',
 | 
				
			||||||
| 
						 | 
					@ -154,12 +153,12 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', co(function* (t) {
 | 
				
			||||||
		latitude: 52.542417,
 | 
							latitude: 52.542417,
 | 
				
			||||||
		longitude: 13.350437
 | 
							longitude: 13.350437
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(blnSchwedterStr, atze, {
 | 
						const journeys = await client.journeys(blnSchwedterStr, atze, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -167,31 +166,31 @@ test('Berlin Schwedter Str. to ATZE Musiktheater', co(function* (t) {
 | 
				
			||||||
		to: atze
 | 
							to: atze
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – with detour', co(function* (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 = yield client.journeys(westhafen, wedding, {
 | 
						const journeys = await client.journeys(westhafen, wedding, {
 | 
				
			||||||
		via: württembergallee,
 | 
							via: württembergallee,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [württembergallee]
 | 
							detourIds: [württembergallee]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: without detour
 | 
					// todo: without detour
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
 | 
					test('earlier/later journeys, Jungfernheide -> München Hbf', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -201,20 +200,20 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys – leg cycle & alternatives', co(function* (t) {
 | 
					test.skip('journeys – leg cycle & alternatives', async (t) => {
 | 
				
			||||||
	yield testLegCycleAlternatives({
 | 
						await testLegCycleAlternatives({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		fromId: blnTiergarten,
 | 
							fromId: blnTiergarten,
 | 
				
			||||||
		toId: blnJannowitzbrücke
 | 
							toId: blnJannowitzbrücke
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -224,17 +223,17 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(berlinHbf, münchenHbf, {
 | 
						const journeys = await client.journeys(berlinHbf, münchenHbf, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const validateJourneyLeg = createValidateJourneyLeg(cfg)
 | 
						const validateJourneyLeg = createValidateJourneyLeg(cfg)
 | 
				
			||||||
	const validate = createValidate(cfg, {
 | 
						const validate = createValidate(cfg, {
 | 
				
			||||||
| 
						 | 
					@ -246,25 +245,25 @@ test('trip details', co(function* (t) {
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Berlin Schwedter Str.', co(function* (t) {
 | 
					test('departures at Berlin Schwedter Str.', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(blnSchwedterStr, {
 | 
						const departures = await client.departures(blnSchwedterStr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: blnSchwedterStr
 | 
							id: blnSchwedterStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: jungfernheide,
 | 
							id: jungfernheide,
 | 
				
			||||||
		name: 'Berlin Jungfernheide',
 | 
							name: 'Berlin Jungfernheide',
 | 
				
			||||||
| 
						 | 
					@ -277,10 +276,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function* (t) {
 | 
					test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -290,10 +289,10 @@ test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function*
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures without related stations', co(function* (t) {
 | 
					test('departures without related stations', async (t) => {
 | 
				
			||||||
	yield testDeparturesWithoutRelatedStations({
 | 
						await testDeparturesWithoutRelatedStations({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		id: '8089051', // Berlin Yorckstr. (S1)
 | 
							id: '8089051', // Berlin Yorckstr. (S1)
 | 
				
			||||||
| 
						 | 
					@ -302,25 +301,25 @@ test('departures without related stations', co(function* (t) {
 | 
				
			||||||
		linesOfRelatedStations: ['S 2', 'S 25', 'S 26', 'U 7']
 | 
							linesOfRelatedStations: ['S 2', 'S 25', 'S 26', 'U 7']
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals at Berlin Schwedter Str.', co(function* (t) {
 | 
					test('arrivals at Berlin Schwedter Str.', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(blnSchwedterStr, {
 | 
						const arrivals = await client.arrivals(blnSchwedterStr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: blnSchwedterStr
 | 
							id: blnSchwedterStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby Berlin Jungfernheide', co(function* (t) {
 | 
					test('nearby Berlin Jungfernheide', async (t) => {
 | 
				
			||||||
	const nearby = yield client.nearby({
 | 
						const nearby = await client.nearby({
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 52.530273,
 | 
							latitude: 52.530273,
 | 
				
			||||||
		longitude: 13.299433
 | 
							longitude: 13.299433
 | 
				
			||||||
| 
						 | 
					@ -341,10 +340,10 @@ test('nearby Berlin Jungfernheide', co(function* (t) {
 | 
				
			||||||
	t.ok(s0.distance <= 100)
 | 
						t.ok(s0.distance <= 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named Jungfernheide', co(function* (t) {
 | 
					test('locations named Jungfernheide', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Jungfernheide', {
 | 
						const locations = await client.locations('Jungfernheide', {
 | 
				
			||||||
		results: 10
 | 
							results: 10
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -355,27 +354,27 @@ test('locations named Jungfernheide', co(function* (t) {
 | 
				
			||||||
	}), 'Jungfernheide not found')
 | 
						}), 'Jungfernheide not found')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const s = yield client.station(regensburgHbf)
 | 
						const s = await client.station(regensburgHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, regensburgHbf)
 | 
						t.equal(s.id, regensburgHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('line with additionalName', co(function* (t) {
 | 
					test('line with additionalName', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(potsdamHbf, {
 | 
						const departures = await client.departures(potsdamHbf, {
 | 
				
			||||||
		duration: 12 * 60, // 12 minutes
 | 
							duration: 12 * 60, // 12 minutes
 | 
				
			||||||
		products: {bus: false, suburban: false, tram: false}
 | 
							products: {bus: false, suburban: false, tram: false}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.ok(departures.some(d => d.line && d.line.additionalName))
 | 
						t.ok(departures.some(d => d.line && d.line.additionalName))
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	const torfstr17 = {
 | 
						const torfstr17 = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Torfstraße 17',
 | 
							address: 'Torfstraße 17',
 | 
				
			||||||
| 
						 | 
					@ -383,7 +382,7 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		longitude: 13.3491223
 | 
							longitude: 13.3491223
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: torfstr17,
 | 
							address: torfstr17,
 | 
				
			||||||
| 
						 | 
					@ -392,4 +391,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										93
									
								
								test/insa.js
									
										
									
									
									
								
							
							
						
						
									
										93
									
								
								test/insa.js
									
										
									
									
									
								
							| 
						 | 
					@ -5,7 +5,6 @@ const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const insaProfile = require('../p/insa')
 | 
					const insaProfile = require('../p/insa')
 | 
				
			||||||
const products = require('../p/insa/products')
 | 
					const products = require('../p/insa/products')
 | 
				
			||||||
| 
						 | 
					@ -47,14 +46,14 @@ const stendal = '8010334'
 | 
				
			||||||
const dessau = '8010077'
 | 
					const dessau = '8010077'
 | 
				
			||||||
const universitaet = '19686'
 | 
					const universitaet = '19686'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Magdeburg Hbf to Magdeburg-Buckau', co(function* (t) {
 | 
					test('journeys – Magdeburg Hbf to Magdeburg-Buckau', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
 | 
						const journeys = await client.journeys(magdeburgHbf, magdeburgBuckau, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -62,7 +61,7 @@ test('journeys – Magdeburg Hbf to Magdeburg-Buckau', co(function* (t) {
 | 
				
			||||||
		toId: magdeburgBuckau
 | 
							toId: magdeburgBuckau
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +77,7 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
					test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
 | 
				
			||||||
	const sternStr = {
 | 
						const sternStr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Magdeburg - Altenstadt, Sternstraße 10',
 | 
							address: 'Magdeburg - Altenstadt, Sternstraße 10',
 | 
				
			||||||
| 
						 | 
					@ -86,12 +85,12 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
				
			||||||
		longitude: 11.422332
 | 
							longitude: 11.422332
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const journeys = yield client.journeys(magdeburgHbf, sternStr, {
 | 
						const journeys = await client.journeys(magdeburgHbf, sternStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -99,9 +98,9 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
				
			||||||
		to: sternStr
 | 
							to: sternStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
					test('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
 | 
				
			||||||
	const kloster = {
 | 
						const kloster = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '970012223',
 | 
							id: '970012223',
 | 
				
			||||||
| 
						 | 
					@ -109,12 +108,12 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
				
			||||||
		latitude: 52.127601,
 | 
							latitude: 52.127601,
 | 
				
			||||||
		longitude: 11.636437
 | 
							longitude: 11.636437
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(magdeburgHbf, kloster, {
 | 
						const journeys = await client.journeys(magdeburgHbf, kloster, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -122,32 +121,32 @@ test('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
				
			||||||
		to: kloster
 | 
							to: kloster
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – with detour', co(function* (t) {
 | 
					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 = yield client.journeys(hasselbachplatzSternstrasse, stendal, {
 | 
						const journeys = await client.journeys(hasselbachplatzSternstrasse, stendal, {
 | 
				
			||||||
		via: dessau,
 | 
							via: dessau,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [dessau]
 | 
							detourIds: [dessau]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: without detour
 | 
					// todo: without detour
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys', co(function* (t) {
 | 
					test('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -157,39 +156,39 @@ test('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
 | 
						const journeys = await client.journeys(magdeburgHbf, magdeburgBuckau, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Magdeburg Leiterstr.', co(function*(t) {
 | 
					test('departures at Magdeburg Leiterstr.', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(leiterstr, {
 | 
						const departures = await client.departures(leiterstr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: leiterstr
 | 
							id: leiterstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: magdeburgHbf,
 | 
							id: magdeburgHbf,
 | 
				
			||||||
		name: 'Magdeburg Hbf',
 | 
							name: 'Magdeburg Hbf',
 | 
				
			||||||
| 
						 | 
					@ -202,10 +201,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Leiterstr in direction of Universität', co(function* (t) {
 | 
					test('departures at Leiterstr in direction of Universität', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -215,27 +214,27 @@ test('departures at Leiterstr in direction of Universität', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals at Magdeburg Leiterstr.', co(function*(t) {
 | 
					test('arrivals at Magdeburg Leiterstr.', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(leiterstr, {
 | 
						const arrivals = await client.arrivals(leiterstr, {
 | 
				
			||||||
		duration: 5, when
 | 
							duration: 5, when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: leiterstr
 | 
							id: leiterstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: nearby
 | 
					// todo: nearby
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named Magdeburg', co(function*(t) {
 | 
					test('locations named Magdeburg', async (t) => {
 | 
				
			||||||
	const nordpark = '7480'
 | 
						const nordpark = '7480'
 | 
				
			||||||
	const locations = yield client.locations('nordpark', {
 | 
						const locations = await client.locations('nordpark', {
 | 
				
			||||||
		results: 20
 | 
							results: 20
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -249,19 +248,19 @@ test('locations named Magdeburg', co(function*(t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station Magdeburg-Buckau', co(function* (t) {
 | 
					test('station Magdeburg-Buckau', async (t) => {
 | 
				
			||||||
	const s = yield client.station(magdeburgBuckau)
 | 
						const s = await client.station(magdeburgBuckau)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, magdeburgBuckau)
 | 
						t.equal(s.id, magdeburgBuckau)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 52.148364,
 | 
							north: 52.148364,
 | 
				
			||||||
		west: 11.600826,
 | 
							west: 11.600826,
 | 
				
			||||||
		south: 52.108486,
 | 
							south: 52.108486,
 | 
				
			||||||
| 
						 | 
					@ -277,4 +276,4 @@ test('radar', co(function* (t) {
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testArrivals = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testArrivals = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, arrivals: arrs, validate, id} = cfg
 | 
						const {test: t, arrivals: arrs, validate, id} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, arrs, 'arrivals', 'arrivals')
 | 
						validate(t, arrs, 'arrivals', 'arrivals')
 | 
				
			||||||
| 
						 | 
					@ -20,6 +18,6 @@ const testArrivals = co(function* (cfg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// todo: move into arrivals validator
 | 
						// todo: move into arrivals validator
 | 
				
			||||||
	t.deepEqual(arrs, arrs.sort((a, b) => t.when > b.when))
 | 
						t.deepEqual(arrs, arrs.sort((a, b) => t.when > b.when))
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testArrivals
 | 
					module.exports = testArrivals
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,33 +0,0 @@
 | 
				
			||||||
'use strict'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// https://github.com/babel/babel/blob/3c8d831fe41f502cbe2459a271d19c7329ffe369/packages/babel-helpers/src/helpers.js#L242-L270
 | 
					 | 
				
			||||||
const co = (fn) => {
 | 
					 | 
				
			||||||
	return function run () {
 | 
					 | 
				
			||||||
		const self = this, args = arguments
 | 
					 | 
				
			||||||
		return new Promise((resolve, reject) => {
 | 
					 | 
				
			||||||
			const gen = fn.apply(self, args)
 | 
					 | 
				
			||||||
			const step = (key, arg) => {
 | 
					 | 
				
			||||||
				try {
 | 
					 | 
				
			||||||
					var info = gen[key](arg)
 | 
					 | 
				
			||||||
					var value = info.value
 | 
					 | 
				
			||||||
				} catch (error) {
 | 
					 | 
				
			||||||
					reject(error)
 | 
					 | 
				
			||||||
					return
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (info.done) resolve(value)
 | 
					 | 
				
			||||||
				else Promise.resolve(value).then(_next, _throw)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			const _next = (value) => {
 | 
					 | 
				
			||||||
				step('next', value)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			const _throw = (err) => {
 | 
					 | 
				
			||||||
				step('throw', err)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			_next()
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = co
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testDeparturesInDirection = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testDeparturesInDirection = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures,
 | 
							fetchDepartures,
 | 
				
			||||||
| 
						 | 
					@ -13,7 +11,7 @@ const testDeparturesInDirection = co(function* (cfg) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	} = cfg
 | 
						} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const deps = yield fetchDepartures(id, {
 | 
						const deps = await fetchDepartures(id, {
 | 
				
			||||||
		direction: directionIds[0],
 | 
							direction: directionIds[0],
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
| 
						 | 
					@ -25,7 +23,7 @@ const testDeparturesInDirection = co(function* (cfg) {
 | 
				
			||||||
		const name = `deps[${i}]`
 | 
							const name = `deps[${i}]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const line = dep.line && dep.line.name
 | 
							const line = dep.line && dep.line.name
 | 
				
			||||||
		const trip = yield fetchTrip(dep.tripId, line, {
 | 
							const trip = await fetchTrip(dep.tripId, line, {
 | 
				
			||||||
			when, stopovers: true
 | 
								when, stopovers: true
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		t.ok(trip.stopovers.some(st => (
 | 
							t.ok(trip.stopovers.some(st => (
 | 
				
			||||||
| 
						 | 
					@ -33,6 +31,6 @@ const testDeparturesInDirection = co(function* (cfg) {
 | 
				
			||||||
			directionIds.includes(st.stop.id)
 | 
								directionIds.includes(st.stop.id)
 | 
				
			||||||
		)), `trip ${dep.tripId} of ${name} has no stopover at ${directionIds}`)
 | 
							)), `trip ${dep.tripId} of ${name} has no stopover at ${directionIds}`)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testDeparturesInDirection
 | 
					module.exports = testDeparturesInDirection
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testDeparturesWithoutUnrelatedStations = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testDeparturesWithoutUnrelatedStations = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures,
 | 
							fetchDepartures,
 | 
				
			||||||
| 
						 | 
					@ -19,14 +17,14 @@ const testDeparturesWithoutUnrelatedStations = co(function* (cfg) {
 | 
				
			||||||
		return relatedLines.includes(dep.line.name.toLowerCase().trim())
 | 
							return relatedLines.includes(dep.line.name.toLowerCase().trim())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const depsWith = yield fetchDepartures(id, {
 | 
						const depsWith = await fetchDepartures(id, {
 | 
				
			||||||
		when,
 | 
							when,
 | 
				
			||||||
		duration: cfg.duration || 20,
 | 
							duration: cfg.duration || 20,
 | 
				
			||||||
		products: cfg.products || {}
 | 
							products: cfg.products || {}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.ok(depsWith.some(isUnrelatedLine), 'precondition failed: no line at related station found')
 | 
						t.ok(depsWith.some(isUnrelatedLine), 'precondition failed: no line at related station found')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const depsWithout = yield fetchDepartures(id, {
 | 
						const depsWithout = await fetchDepartures(id, {
 | 
				
			||||||
		includeRelatedStations: false,
 | 
							includeRelatedStations: false,
 | 
				
			||||||
		when,
 | 
							when,
 | 
				
			||||||
		duration: cfg.duration || 20,
 | 
							duration: cfg.duration || 20,
 | 
				
			||||||
| 
						 | 
					@ -36,6 +34,6 @@ const testDeparturesWithoutUnrelatedStations = co(function* (cfg) {
 | 
				
			||||||
	const unrelatedDep = depsWithout.find(isUnrelatedLine)
 | 
						const unrelatedDep = depsWithout.find(isUnrelatedLine)
 | 
				
			||||||
	if (unrelatedDep) t.fail('line at related station: ' + unrelatedDep.line.name)
 | 
						if (unrelatedDep) t.fail('line at related station: ' + unrelatedDep.line.name)
 | 
				
			||||||
	else t.pass('no lines from related stations')
 | 
						else t.pass('no lines from related stations')
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testDeparturesWithoutUnrelatedStations
 | 
					module.exports = testDeparturesWithoutUnrelatedStations
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testDepartures = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testDepartures = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, departures: deps, validate, id} = cfg
 | 
						const {test: t, departures: deps, validate, id} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
| 
						 | 
					@ -20,6 +18,6 @@ const testDepartures = co(function* (cfg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// todo: move into deps validator
 | 
						// todo: move into deps validator
 | 
				
			||||||
	t.deepEqual(deps, deps.sort((a, b) => t.when > b.when))
 | 
						t.deepEqual(deps, deps.sort((a, b) => t.when > b.when))
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testDepartures
 | 
					module.exports = testDepartures
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testEarlierLaterJourneys = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testEarlierLaterJourneys = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys,
 | 
							fetchJourneys,
 | 
				
			||||||
| 
						 | 
					@ -12,7 +10,7 @@ const testEarlierLaterJourneys = co(function* (cfg) {
 | 
				
			||||||
		// todo: validate
 | 
							// todo: validate
 | 
				
			||||||
	} = cfg
 | 
						} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const model = yield fetchJourneys(fromId, toId, {
 | 
						const model = await fetchJourneys(fromId, toId, {
 | 
				
			||||||
		results: 3, departure: when
 | 
							results: 3, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +58,7 @@ const testEarlierLaterJourneys = co(function* (cfg) {
 | 
				
			||||||
		else if (dep > latestDep) latestDep = dep
 | 
							else if (dep > latestDep) latestDep = dep
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const earlier = yield fetchJourneys(fromId, toId, {
 | 
						const earlier = await fetchJourneys(fromId, toId, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		// todo: single journey ref?
 | 
							// todo: single journey ref?
 | 
				
			||||||
		earlierThan: model.earlierRef
 | 
							earlierThan: model.earlierRef
 | 
				
			||||||
| 
						 | 
					@ -71,7 +69,7 @@ const testEarlierLaterJourneys = co(function* (cfg) {
 | 
				
			||||||
		t.ok(dep < earliestDep)
 | 
							t.ok(dep < earliestDep)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const later = yield fetchJourneys(fromId, toId, {
 | 
						const later = await fetchJourneys(fromId, toId, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		// todo: single journey ref?
 | 
							// todo: single journey ref?
 | 
				
			||||||
		laterThan: model.laterRef
 | 
							laterThan: model.laterRef
 | 
				
			||||||
| 
						 | 
					@ -81,6 +79,6 @@ const testEarlierLaterJourneys = co(function* (cfg) {
 | 
				
			||||||
		const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
 | 
							const dep = new Date(firstLeg.departure || firstLeg.formerScheduledDeparture)
 | 
				
			||||||
		t.ok(dep > latestDep)
 | 
							t.ok(dep > latestDep)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testEarlierLaterJourneys
 | 
					module.exports = testEarlierLaterJourneys
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,9 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testJourneysStationToAddress = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testJourneysStationToAddress = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, journeys, validate, fromId} = cfg
 | 
						const {test: t, journeys, validate, fromId} = cfg
 | 
				
			||||||
	const {address, latitude, longitude} = cfg.to
 | 
						const {address, latitude, longitude} = cfg.to
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +23,6 @@ const testJourneysStationToAddress = co(function* (cfg) {
 | 
				
			||||||
		t.ok(isRoughlyEqual(.0001, d.latitude, latitude), n + '.latitude is invalid')
 | 
							t.ok(isRoughlyEqual(.0001, d.latitude, latitude), n + '.latitude is invalid')
 | 
				
			||||||
		t.ok(isRoughlyEqual(.0001, d.longitude, longitude), n + '.longitude is invalid')
 | 
							t.ok(isRoughlyEqual(.0001, d.longitude, longitude), n + '.longitude is invalid')
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testJourneysStationToAddress
 | 
					module.exports = testJourneysStationToAddress
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,9 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testJourneysStationToPoi = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testJourneysStationToPoi = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, journeys, validate, fromId} = cfg
 | 
						const {test: t, journeys, validate, fromId} = cfg
 | 
				
			||||||
	const {id, name, latitude, longitude} = cfg.to
 | 
						const {id, name, latitude, longitude} = cfg.to
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +32,6 @@ const testJourneysStationToPoi = co(function* (cfg) {
 | 
				
			||||||
		t.ok(isRoughlyEqual(.0001, d.latitude, latitude), dN + '.latitude is invalid')
 | 
							t.ok(isRoughlyEqual(.0001, d.latitude, latitude), dN + '.latitude is invalid')
 | 
				
			||||||
		t.ok(isRoughlyEqual(.0001, d.longitude, longitude), dN + '.longitude is invalid')
 | 
							t.ok(isRoughlyEqual(.0001, d.longitude, longitude), dN + '.longitude is invalid')
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testJourneysStationToPoi
 | 
					module.exports = testJourneysStationToPoi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testJourneysStationToStation = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testJourneysStationToStation = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, journeys, validate, fromId, toId} = cfg
 | 
						const {test: t, journeys, validate, fromId, toId} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, journeys, 'journeys', 'journeys')
 | 
						validate(t, journeys, 'journeys', 'journeys')
 | 
				
			||||||
| 
						 | 
					@ -17,6 +15,6 @@ const testJourneysStationToStation = co(function* (cfg) {
 | 
				
			||||||
		t.strictEqual(origin.id, fromId)
 | 
							t.strictEqual(origin.id, fromId)
 | 
				
			||||||
		t.strictEqual(dest.id, toId)
 | 
							t.strictEqual(dest.id, toId)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testJourneysStationToStation
 | 
					module.exports = testJourneysStationToStation
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,6 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testJourneysWithDetour = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testJourneysWithDetour = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {test: t, journeys, validate, detourIds} = cfg
 | 
						const {test: t, journeys, 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
 | 
				
			||||||
| 
						 | 
					@ -17,6 +15,6 @@ const testJourneysWithDetour = co(function* (cfg) {
 | 
				
			||||||
		))
 | 
							))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.ok(leg, detourIds.join('/') + ' is not being passed')
 | 
						t.ok(leg, detourIds.join('/') + ' is not being passed')
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testJourneysWithDetour
 | 
					module.exports = testJourneysWithDetour
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,10 +2,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					 | 
				
			||||||
const {hour} = require('./util')
 | 
					const {hour} = require('./util')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const testLegCycleAlternatives = co(function* (cfg) {
 | 
					const testLegCycleAlternatives = async (cfg) => {
 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys,
 | 
							fetchJourneys,
 | 
				
			||||||
| 
						 | 
					@ -15,7 +14,7 @@ const testLegCycleAlternatives = co(function* (cfg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Apparently HAFAS doesn't return the leg cycle or alternatives more
 | 
						// Apparently HAFAS doesn't return the leg cycle or alternatives more
 | 
				
			||||||
	// than ~2 hours in advance. This is why we don't pass `when` here.
 | 
						// than ~2 hours in advance. This is why we don't pass `when` here.
 | 
				
			||||||
	const journeys = yield fetchJourneys(fromId, toId, {results: 3})
 | 
						const journeys = await fetchJourneys(fromId, toId, {results: 3})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (let i = 0; i < journeys.length; i++) {
 | 
						for (let i = 0; i < journeys.length; i++) {
 | 
				
			||||||
		const journey = journeys[i]
 | 
							const journey = journeys[i]
 | 
				
			||||||
| 
						 | 
					@ -42,6 +41,6 @@ const testLegCycleAlternatives = co(function* (cfg) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testLegCycleAlternatives
 | 
					module.exports = testLegCycleAlternatives
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,9 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isPlainObject = require('lodash/isPlainObject')
 | 
					const isPlainObject = require('lodash/isPlainObject')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					const testReachableFrom = async (cfg) => {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const testReachableFrom = co(function* (cfg) {
 | 
					 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom,
 | 
							reachableFrom,
 | 
				
			||||||
| 
						 | 
					@ -14,7 +12,7 @@ const testReachableFrom = co(function* (cfg) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	} = cfg
 | 
						} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const results = yield reachableFrom(address, {
 | 
						const results = await reachableFrom(address, {
 | 
				
			||||||
		when, maxDuration
 | 
							when, maxDuration
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +37,6 @@ const testReachableFrom = co(function* (cfg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const sorted = results.sort((a, b) => a.duration - b.duration)
 | 
						const sorted = results.sort((a, b) => a.duration - b.duration)
 | 
				
			||||||
	t.deepEqual(results, sorted, 'results must be sorted by res.duration')
 | 
						t.deepEqual(results, sorted, 'results must be sorted by res.duration')
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testReachableFrom
 | 
					module.exports = testReachableFrom
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,5 @@
 | 
				
			||||||
'use strict'
 | 
					'use strict'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./co')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const simplify = j => j.legs.map(l => {
 | 
					const simplify = j => j.legs.map(l => {
 | 
				
			||||||
	let departure = null
 | 
						let departure = null
 | 
				
			||||||
	if (l.departure) {
 | 
						if (l.departure) {
 | 
				
			||||||
| 
						 | 
					@ -22,7 +20,7 @@ const simplify = j => j.legs.map(l => {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const testRefreshJourney = co(function* (cfg) {
 | 
					const testRefreshJourney = async (cfg) => {
 | 
				
			||||||
	const {
 | 
						const {
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys,
 | 
							fetchJourneys,
 | 
				
			||||||
| 
						 | 
					@ -33,7 +31,7 @@ const testRefreshJourney = co(function* (cfg) {
 | 
				
			||||||
		// todo: validate
 | 
							// todo: validate
 | 
				
			||||||
	} = cfg
 | 
						} = cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const [model] = yield fetchJourneys(fromId, toId, {
 | 
						const [model] = await fetchJourneys(fromId, toId, {
 | 
				
			||||||
		results: 1, departure: when,
 | 
							results: 1, departure: when,
 | 
				
			||||||
		stopovers: false
 | 
							stopovers: false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
| 
						 | 
					@ -42,10 +40,10 @@ const testRefreshJourney = co(function* (cfg) {
 | 
				
			||||||
	t.equal(typeof model.refreshToken, 'string')
 | 
						t.equal(typeof model.refreshToken, 'string')
 | 
				
			||||||
	t.ok(model.refreshToken)
 | 
						t.ok(model.refreshToken)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const refreshed = yield refreshJourney(model.refreshToken, {
 | 
						const refreshed = await refreshJourney(model.refreshToken, {
 | 
				
			||||||
		stopovers: false
 | 
							stopovers: false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.deepEqual(simplify(refreshed), simplify(model))
 | 
						t.deepEqual(simplify(refreshed), simplify(model))
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = testRefreshJourney
 | 
					module.exports = testRefreshJourney
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										109
									
								
								test/nahsh.js
									
										
									
									
									
								
							
							
						
						
									
										109
									
								
								test/nahsh.js
									
										
									
									
									
								
							| 
						 | 
					@ -5,7 +5,6 @@ const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const nahshProfile = require('../p/nahsh')
 | 
					const nahshProfile = require('../p/nahsh')
 | 
				
			||||||
const products = require('../p/nahsh/products')
 | 
					const products = require('../p/nahsh/products')
 | 
				
			||||||
| 
						 | 
					@ -76,14 +75,14 @@ const ellerbekerMarkt = '9049027'
 | 
				
			||||||
const seefischmarkt = '9049245'
 | 
					const seefischmarkt = '9049245'
 | 
				
			||||||
const kielRaeucherei = '9049217'
 | 
					const kielRaeucherei = '9049217'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Kiel Hbf to Flensburg', co(function* (t) {
 | 
					test('journeys – Kiel Hbf to Flensburg', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(kielHbf, flensburg, {
 | 
						const journeys = await client.journeys(kielHbf, flensburg, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -98,7 +97,7 @@ test('journeys – Kiel Hbf to Flensburg', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,19 +113,19 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Kiel Hbf to Berliner Str. 80, Husum', co(function* (t) {
 | 
					test('Kiel Hbf to Berliner Str. 80, Husum', async (t) => {
 | 
				
			||||||
	const berlinerStr = {
 | 
						const berlinerStr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Husum, Berliner Straße 80',
 | 
							address: 'Husum, Berliner Straße 80',
 | 
				
			||||||
		latitude: 54.488995,
 | 
							latitude: 54.488995,
 | 
				
			||||||
		longitude: 9.056263
 | 
							longitude: 9.056263
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(kielHbf, berlinerStr, {
 | 
						const journeys = await client.journeys(kielHbf, berlinerStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -134,9 +133,9 @@ test('Kiel Hbf to Berliner Str. 80, Husum', co(function* (t) {
 | 
				
			||||||
		to: berlinerStr
 | 
							to: berlinerStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Kiel Hbf to Holstentor', co(function* (t) {
 | 
					test('Kiel Hbf to Holstentor', async (t) => {
 | 
				
			||||||
	const holstentor = {
 | 
						const holstentor = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '970003118',
 | 
							id: '970003118',
 | 
				
			||||||
| 
						 | 
					@ -144,12 +143,12 @@ test('Kiel Hbf to Holstentor', co(function* (t) {
 | 
				
			||||||
		latitude: 53.866321,
 | 
							latitude: 53.866321,
 | 
				
			||||||
		longitude: 10.679976
 | 
							longitude: 10.679976
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(kielHbf, holstentor, {
 | 
						const journeys = await client.journeys(kielHbf, holstentor, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -157,10 +156,10 @@ test('Kiel Hbf to Holstentor', co(function* (t) {
 | 
				
			||||||
		to: holstentor
 | 
							to: holstentor
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Husum to Lübeck Hbf with stopover at Kiel Hbf', co(function* (t) {
 | 
					test('Husum to Lübeck Hbf with stopover at Kiel Hbf', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(husum, luebeckHbf, {
 | 
						const journeys = await client.journeys(husum, luebeckHbf, {
 | 
				
			||||||
		via: kielHbf,
 | 
							via: kielHbf,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
| 
						 | 
					@ -178,10 +177,10 @@ test('Husum to Lübeck Hbf with stopover at Kiel Hbf', co(function* (t) {
 | 
				
			||||||
	t.ok(leg, 'Kiel Hbf is not being passed')
 | 
						t.ok(leg, 'Kiel Hbf is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
 | 
					test('earlier/later journeys, Kiel Hbf -> Flensburg', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -191,10 +190,10 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -204,42 +203,42 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: with detour test
 | 
					// todo: with detour test
 | 
				
			||||||
// todo: without detour test
 | 
					// todo: without detour test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(flensburg, husum, {
 | 
						const journeys = await client.journeys(flensburg, husum, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Kiel Räucherei', co(function* (t) {
 | 
					test('departures at Kiel Räucherei', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(kielRaeucherei, {
 | 
						const departures = await client.departures(kielRaeucherei, {
 | 
				
			||||||
		duration: 30, when,
 | 
							duration: 30, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: kielRaeucherei
 | 
							id: kielRaeucherei
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: kielHbf,
 | 
							id: kielHbf,
 | 
				
			||||||
		name: 'Kiel Hbf',
 | 
							name: 'Kiel Hbf',
 | 
				
			||||||
| 
						 | 
					@ -252,10 +251,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function* (t) {
 | 
					test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -265,29 +264,29 @@ test('departures at Berlin Hbf in direction of Berlin Ostbahnhof', co(function*
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals at Kiel Räucherei', co(function* (t) {
 | 
					test('arrivals at Kiel Räucherei', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(kielRaeucherei, {
 | 
						const arrivals = await client.arrivals(kielRaeucherei, {
 | 
				
			||||||
		duration: 30, when
 | 
							duration: 30, when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: kielRaeucherei
 | 
							id: kielRaeucherei
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby Kiel Hbf', co(function* (t) {
 | 
					test('nearby Kiel Hbf', async (t) => {
 | 
				
			||||||
	const kielHbfPosition = {
 | 
						const kielHbfPosition = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 54.314982,
 | 
							latitude: 54.314982,
 | 
				
			||||||
		longitude: 10.131976
 | 
							longitude: 10.131976
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const nearby = yield client.nearby(kielHbfPosition, {
 | 
						const nearby = await client.nearby(kielHbfPosition, {
 | 
				
			||||||
		results: 2, distance: 400
 | 
							results: 2, distance: 400
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -302,11 +301,11 @@ test('nearby Kiel Hbf', co(function* (t) {
 | 
				
			||||||
	t.ok(nearby[0].distance <= 100)
 | 
						t.ok(nearby[0].distance <= 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named "Kiel Rathaus"', co(function* (t) {
 | 
					test('locations named "Kiel Rathaus"', async (t) => {
 | 
				
			||||||
	const kielRathaus = '9049200'
 | 
						const kielRathaus = '9049200'
 | 
				
			||||||
	const locations = yield client.locations('Kiel Rathaus', {
 | 
						const locations = await client.locations('Kiel Rathaus', {
 | 
				
			||||||
		results: 15
 | 
							results: 15
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -318,19 +317,19 @@ test('locations named "Kiel Rathaus"', co(function* (t) {
 | 
				
			||||||
	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()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const s = yield client.station(kielHbf)
 | 
						const s = await client.station(kielHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, kielHbf)
 | 
						t.equal(s.id, kielHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 54.4,
 | 
							north: 54.4,
 | 
				
			||||||
		west: 10.0,
 | 
							west: 10.0,
 | 
				
			||||||
		south: 54.2,
 | 
							south: 54.2,
 | 
				
			||||||
| 
						 | 
					@ -354,9 +353,9 @@ test('radar', co(function* (t) {
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	const berlinerStr = {
 | 
						const berlinerStr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Husum, Berliner Straße 80',
 | 
							address: 'Husum, Berliner Straße 80',
 | 
				
			||||||
| 
						 | 
					@ -364,7 +363,7 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		longitude: 9.056263
 | 
							longitude: 9.056263
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: berlinerStr,
 | 
							address: berlinerStr,
 | 
				
			||||||
| 
						 | 
					@ -373,4 +372,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										101
									
								
								test/oebb.js
									
										
									
									
									
								
							
							
						
						
									
										101
									
								
								test/oebb.js
									
										
									
									
									
								
							| 
						 | 
					@ -6,7 +6,6 @@ const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
const validateLine = require('validate-fptf/line')
 | 
					const validateLine = require('validate-fptf/line')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const oebbProfile = require('../p/oebb')
 | 
					const oebbProfile = require('../p/oebb')
 | 
				
			||||||
const products = require('../p/oebb/products')
 | 
					const products = require('../p/oebb/products')
 | 
				
			||||||
| 
						 | 
					@ -67,14 +66,14 @@ const wienRenngasse = '1390186'
 | 
				
			||||||
const wienKarlsplatz = '1390461'
 | 
					const wienKarlsplatz = '1390461'
 | 
				
			||||||
const wienPilgramgasse = '1390562'
 | 
					const wienPilgramgasse = '1390562'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
 | 
					test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(salzburgHbf, wienFickeystr, {
 | 
						const journeys = await client.journeys(salzburgHbf, wienFickeystr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -88,7 +87,7 @@ test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,19 +103,19 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
 | 
					test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', async (t) => {
 | 
				
			||||||
	const wagramerStr = {
 | 
						const wagramerStr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
    	address: '1220 Wien, Wagramer Straße 5',
 | 
					    	address: '1220 Wien, Wagramer Straße 5',
 | 
				
			||||||
    	latitude: 48.236216,
 | 
					    	latitude: 48.236216,
 | 
				
			||||||
    	longitude: 16.425863
 | 
					    	longitude: 16.425863
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(salzburgHbf, wagramerStr, {
 | 
						const journeys = await client.journeys(salzburgHbf, wagramerStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -124,9 +123,9 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
 | 
				
			||||||
		to: wagramerStr
 | 
							to: wagramerStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Salzburg Hbf to Albertina', co(function* (t) {
 | 
					test('Salzburg Hbf to Albertina', async (t) => {
 | 
				
			||||||
	const albertina = {
 | 
						const albertina = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
    	id: '975900003',
 | 
					    	id: '975900003',
 | 
				
			||||||
| 
						 | 
					@ -134,11 +133,11 @@ test('Salzburg Hbf to Albertina', co(function* (t) {
 | 
				
			||||||
    	latitude: 48.204699,
 | 
					    	latitude: 48.204699,
 | 
				
			||||||
    	longitude: 16.368404
 | 
					    	longitude: 16.368404
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(salzburgHbf, albertina, {
 | 
						const journeys = await client.journeys(salzburgHbf, albertina, {
 | 
				
			||||||
		results: 3, departure: when
 | 
							results: 3, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -146,32 +145,32 @@ test('Salzburg Hbf to Albertina', co(function* (t) {
 | 
				
			||||||
		to: albertina
 | 
							to: albertina
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – with detour', co(function* (t) {
 | 
					test('journeys: via works – with detour', async (t) => {
 | 
				
			||||||
	// Going from Stephansplatz to Schottenring via Donauinsel without detour
 | 
						// Going from Stephansplatz to Schottenring via Donauinsel 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 stephansplatz = '1390167'
 | 
						const stephansplatz = '1390167'
 | 
				
			||||||
	const schottenring = '1390163'
 | 
						const schottenring = '1390163'
 | 
				
			||||||
	const donauinsel = '1392277'
 | 
						const donauinsel = '1392277'
 | 
				
			||||||
	const donauinselPassed = '922001'
 | 
						const donauinselPassed = '922001'
 | 
				
			||||||
	const journeys = yield client.journeys(stephansplatz, schottenring, {
 | 
						const journeys = await client.journeys(stephansplatz, schottenring, {
 | 
				
			||||||
		via: donauinsel,
 | 
							via: donauinsel,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [donauinsel, donauinselPassed]
 | 
							detourIds: [donauinsel, donauinselPassed]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – without detour', co(function* (t) {
 | 
					test('journeys: via works – without detour', async (t) => {
 | 
				
			||||||
	// When going from Karlsplatz to Praterstern via Museumsquartier, there is
 | 
						// When going from Karlsplatz to Praterstern via Museumsquartier, there is
 | 
				
			||||||
	// *no need* to change trains / no need for a "detour".
 | 
						// *no need* to change trains / no need for a "detour".
 | 
				
			||||||
	const karlsplatz = '1390461'
 | 
						const karlsplatz = '1390461'
 | 
				
			||||||
| 
						 | 
					@ -179,7 +178,7 @@ test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
	const museumsquartier = '1390171'
 | 
						const museumsquartier = '1390171'
 | 
				
			||||||
	const museumsquartierPassed = '901014'
 | 
						const museumsquartierPassed = '901014'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const journeys = yield client.journeys(karlsplatz, praterstern, {
 | 
						const journeys = await client.journeys(karlsplatz, praterstern, {
 | 
				
			||||||
		via: museumsquartier,
 | 
							via: museumsquartier,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
| 
						 | 
					@ -204,10 +203,10 @@ test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
	t.ok(l2, 'Museumsquartier is not being passed')
 | 
						t.ok(l2, 'Museumsquartier is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t) {
 | 
					test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -217,10 +216,10 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -230,23 +229,23 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(wienWestbahnhof, muenchenHbf, {
 | 
						const journeys = await client.journeys(wienWestbahnhof, muenchenHbf, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Wien Leibenfrostgasse', co(function* (t) {
 | 
					test('departures at Wien Leibenfrostgasse', async (t) => {
 | 
				
			||||||
	const wienLeibenfrostgasse = '1390469'
 | 
						const wienLeibenfrostgasse = '1390469'
 | 
				
			||||||
	const ids = [
 | 
						const ids = [
 | 
				
			||||||
		wienLeibenfrostgasse, // station
 | 
							wienLeibenfrostgasse, // station
 | 
				
			||||||
| 
						 | 
					@ -254,7 +253,7 @@ test('departures at Wien Leibenfrostgasse', co(function* (t) {
 | 
				
			||||||
		'904030' // stop "Wien Leibenfrostgasse (Ziegelofengasse)"
 | 
							'904030' // stop "Wien Leibenfrostgasse (Ziegelofengasse)"
 | 
				
			||||||
	]
 | 
						]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const deps = yield client.departures(wienLeibenfrostgasse, {
 | 
						const deps = await client.departures(wienLeibenfrostgasse, {
 | 
				
			||||||
		duration: 15, when,
 | 
							duration: 15, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
| 
						 | 
					@ -270,10 +269,10 @@ test('departures at Wien Leibenfrostgasse', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: salzburgHbf,
 | 
							id: salzburgHbf,
 | 
				
			||||||
		name: 'Salzburg Hbf',
 | 
							name: 'Salzburg Hbf',
 | 
				
			||||||
| 
						 | 
					@ -286,10 +285,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Karlsplatz in direction of Pilgramgasse', co(function* (t) {
 | 
					test('departures at Karlsplatz in direction of Pilgramgasse', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -299,12 +298,12 @@ test('departures at Karlsplatz in direction of Pilgramgasse', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: arrivals
 | 
					// todo: arrivals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby Salzburg Hbf', co(function* (t) {
 | 
					test('nearby Salzburg Hbf', async (t) => {
 | 
				
			||||||
	const nearby = yield client.nearby({
 | 
						const nearby = await client.nearby({
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		longitude: 13.045604,
 | 
							longitude: 13.045604,
 | 
				
			||||||
		latitude: 47.812851
 | 
							latitude: 47.812851
 | 
				
			||||||
| 
						 | 
					@ -324,10 +323,10 @@ test('nearby Salzburg Hbf', co(function* (t) {
 | 
				
			||||||
	t.ok(s.distance <= 100)
 | 
						t.ok(s.distance <= 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named Salzburg', co(function* (t) {
 | 
					test('locations named Salzburg', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Salzburg', {
 | 
						const locations = await client.locations('Salzburg', {
 | 
				
			||||||
		results: 20
 | 
							results: 20
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -341,10 +340,10 @@ test('locations named Salzburg', co(function* (t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const loc = yield client.station(wienRenngasse)
 | 
						const loc = await client.station(wienRenngasse)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// todo: find a way to always get products from the API
 | 
						// todo: find a way to always get products from the API
 | 
				
			||||||
	// todo: cfg.stationProductsOptional option
 | 
						// todo: cfg.stationProductsOptional option
 | 
				
			||||||
| 
						 | 
					@ -365,10 +364,10 @@ test('station', co(function* (t) {
 | 
				
			||||||
	t.equal(loc.id, wienRenngasse)
 | 
						t.equal(loc.id, wienRenngasse)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar Salzburg', co(function* (t) {
 | 
					test('radar Salzburg', async (t) => {
 | 
				
			||||||
	let vehicles = yield client.radar({
 | 
						let vehicles = await client.radar({
 | 
				
			||||||
		north: 47.827203,
 | 
							north: 47.827203,
 | 
				
			||||||
		west: 13.001261,
 | 
							west: 13.001261,
 | 
				
			||||||
		south: 47.773278,
 | 
							south: 47.773278,
 | 
				
			||||||
| 
						 | 
					@ -394,4 +393,4 @@ test('radar Salzburg', co(function* (t) {
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,6 @@ const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { createWhen } = require('./lib/util')
 | 
					const { createWhen } = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const saarfahrplanProfile = require('../p/saarfahrplan')
 | 
					const saarfahrplanProfile = require('../p/saarfahrplan')
 | 
				
			||||||
const products = require('../p/saarfahrplan/products')
 | 
					const products = require('../p/saarfahrplan/products')
 | 
				
			||||||
| 
						 | 
					@ -84,13 +83,13 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', co(function * (t) {
 | 
					test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(saarbrueckenHbf, thomasMannStr, {
 | 
						const journeys = await client.journeys(saarbrueckenHbf, thomasMannStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -98,9 +97,9 @@ test('Saarbrücken Hbf to Neunkirchen, Thomas-Mann-Straße 1', co(function * (t)
 | 
				
			||||||
		to: thomasMannStr
 | 
							to: thomasMannStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Saarbrücken Hbf to Schlossberghöhlen', co(function * (t) {
 | 
					test('Saarbrücken Hbf to Schlossberghöhlen', async (t) => {
 | 
				
			||||||
	const schlossberghoehlen = {
 | 
						const schlossberghoehlen = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 49.32071,
 | 
							latitude: 49.32071,
 | 
				
			||||||
| 
						 | 
					@ -108,11 +107,11 @@ test('Saarbrücken Hbf to Schlossberghöhlen', co(function * (t) {
 | 
				
			||||||
		name: 'Homburg, Schlossberghöhlen',
 | 
							name: 'Homburg, Schlossberghöhlen',
 | 
				
			||||||
		id: '9000185'
 | 
							id: '9000185'
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(saarbrueckenHbf, schlossberghoehlen, {
 | 
						const journeys = await client.journeys(saarbrueckenHbf, schlossberghoehlen, {
 | 
				
			||||||
		results: 3, departure: when
 | 
							results: 3, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -120,32 +119,32 @@ test('Saarbrücken Hbf to Schlossberghöhlen', co(function * (t) {
 | 
				
			||||||
		to: schlossberghoehlen
 | 
							to: schlossberghoehlen
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys: via works – with detour', co(function* (t) {
 | 
					test.skip('journeys: via works – with detour', async (t) => {
 | 
				
			||||||
	// Going from Stephansplatz to Schottenring via Donauinsel without detour
 | 
						// Going from Stephansplatz to Schottenring via Donauinsel 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 stephansplatz = '1390167'
 | 
						const stephansplatz = '1390167'
 | 
				
			||||||
	const schottenring = '1390163'
 | 
						const schottenring = '1390163'
 | 
				
			||||||
	const donauinsel = '1392277'
 | 
						const donauinsel = '1392277'
 | 
				
			||||||
	const donauinselPassed = '922001'
 | 
						const donauinselPassed = '922001'
 | 
				
			||||||
	const journeys = yield client.journeys(stephansplatz, schottenring, {
 | 
						const journeys = await client.journeys(stephansplatz, schottenring, {
 | 
				
			||||||
		via: donauinsel,
 | 
							via: donauinsel,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [donauinsel, donauinselPassed]
 | 
							detourIds: [donauinsel, donauinselPassed]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys: via works – without detour', co(function* (t) {
 | 
					test.skip('journeys: via works – without detour', async (t) => {
 | 
				
			||||||
	// When going from Karlsplatz to Praterstern via Museumsquartier, there is
 | 
						// When going from Karlsplatz to Praterstern via Museumsquartier, there is
 | 
				
			||||||
	// *no need* to change trains / no need for a "detour".
 | 
						// *no need* to change trains / no need for a "detour".
 | 
				
			||||||
	const karlsplatz = '1390461'
 | 
						const karlsplatz = '1390461'
 | 
				
			||||||
| 
						 | 
					@ -153,7 +152,7 @@ test.skip('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
	const museumsquartier = '1390171'
 | 
						const museumsquartier = '1390171'
 | 
				
			||||||
	const museumsquartierPassed = '901014'
 | 
						const museumsquartierPassed = '901014'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const journeys = yield client.journeys(karlsplatz, praterstern, {
 | 
						const journeys = await client.journeys(karlsplatz, praterstern, {
 | 
				
			||||||
		via: museumsquartier,
 | 
							via: museumsquartier,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
| 
						 | 
					@ -178,10 +177,10 @@ test.skip('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
	t.ok(l2, 'Museumsquartier is not being passed')
 | 
						t.ok(l2, 'Museumsquartier is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', co(function * (t) {
 | 
					test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -191,24 +190,24 @@ test('earlier/later journeys, Saarbrücken Hbf -> Saarlouis Hbf', co(function *
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function * (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(saarlouisHbf, metzVille, {
 | 
						const journeys = await client.journeys(saarlouisHbf, metzVille, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, { when })
 | 
						const trip = await client.trip(p.id, p.line.name, { when })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures', co(function* (t) {
 | 
					test('departures', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(saarbrueckenUhlandstr, {
 | 
						const departures = await client.departures(saarbrueckenUhlandstr, {
 | 
				
			||||||
		duration: 5, when
 | 
							duration: 5, when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -228,10 +227,10 @@ test('departures', co(function* (t) {
 | 
				
			||||||
	// todo: move into deps validator
 | 
						// todo: move into deps validator
 | 
				
			||||||
	t.deepEqual(departures, departures.sort((a, b) => t.when > b.when))
 | 
						t.deepEqual(departures, departures.sort((a, b) => t.when > b.when))
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with stop object', co(function* (t) {
 | 
					test('departures with stop object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'stop',
 | 
							type: 'stop',
 | 
				
			||||||
		id: '8000323',
 | 
							id: '8000323',
 | 
				
			||||||
		name: 'Saarbrücken Hbf',
 | 
							name: 'Saarbrücken Hbf',
 | 
				
			||||||
| 
						 | 
					@ -244,11 +243,11 @@ test('departures with stop object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Karlsplatz in direction of Pilgramgasse', co(function* (t) {
 | 
					test('departures at Karlsplatz in direction of Pilgramgasse', async (t) => {
 | 
				
			||||||
	const saarbrueckenLandwehrplatz = '10606'
 | 
						const saarbrueckenLandwehrplatz = '10606'
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -258,12 +257,12 @@ test('departures at Karlsplatz in direction of Pilgramgasse', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: arrivals
 | 
					// todo: arrivals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby Saarbrücken Hbf', co(function * (t) {
 | 
					test('nearby Saarbrücken Hbf', async (t) => {
 | 
				
			||||||
	const nearby = yield client.nearby({
 | 
						const nearby = await client.nearby({
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 49.241066,
 | 
							latitude: 49.241066,
 | 
				
			||||||
		longitude: 6.991019
 | 
							longitude: 6.991019
 | 
				
			||||||
| 
						 | 
					@ -283,10 +282,10 @@ test('nearby Saarbrücken Hbf', co(function * (t) {
 | 
				
			||||||
	t.ok(s.distance <= 100)
 | 
						t.ok(s.distance <= 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named Saarbrücken', co(function * (t) {
 | 
					test('locations named Saarbrücken', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Saarbrücken', {
 | 
						const locations = await client.locations('Saarbrücken', {
 | 
				
			||||||
		results: 20
 | 
							results: 20
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -300,19 +299,19 @@ test('locations named Saarbrücken', co(function * (t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const s = yield client.station(saarbrueckenUhlandstr)
 | 
						const s = await client.station(saarbrueckenUhlandstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, saarbrueckenUhlandstr)
 | 
						t.equal(s.id, saarbrueckenUhlandstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 49.27,
 | 
							north: 49.27,
 | 
				
			||||||
		west: 6.97,
 | 
							west: 6.97,
 | 
				
			||||||
		south: 49.22,
 | 
							south: 49.22,
 | 
				
			||||||
| 
						 | 
					@ -323,4 +322,4 @@ test('radar', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,6 @@ const tapePromise = require('tape-promise').default
 | 
				
			||||||
const tape = require('tape')
 | 
					const tape = require('tape')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const sMunichProfile = require('../p/sbahn-muenchen')
 | 
					const sMunichProfile = require('../p/sbahn-muenchen')
 | 
				
			||||||
const products = require('../p/sbahn-muenchen/products')
 | 
					const products = require('../p/sbahn-muenchen/products')
 | 
				
			||||||
| 
						 | 
					@ -63,14 +62,14 @@ const poetschnerstr = {
 | 
				
			||||||
	longitude: 11.531695
 | 
						longitude: 11.531695
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Mittersendling to Karl-Theodor-Straße', co(function* (t) {
 | 
					test('journeys – Mittersendling to Karl-Theodor-Straße', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(mittersendling, karlTheodorStr, {
 | 
						const journeys = await client.journeys(mittersendling, karlTheodorStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -78,7 +77,7 @@ test('journeys – Mittersendling to Karl-Theodor-Straße', co(function* (t) {
 | 
				
			||||||
		toId: karlTheodorStr
 | 
							toId: karlTheodorStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,13 +93,13 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', co(function*(t) {
 | 
					test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(karlTheodorStr, poetschnerstr, {
 | 
						const journeys = await client.journeys(karlTheodorStr, poetschnerstr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -108,9 +107,9 @@ test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', co(function*(t) {
 | 
				
			||||||
		to: poetschnerstr
 | 
							to: poetschnerstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Karl-Theodor-Straße to Hofbräuhaus', co(function*(t) {
 | 
					test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
 | 
				
			||||||
	const hofbraeuhaus = {
 | 
						const hofbraeuhaus = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '970006201',
 | 
							id: '970006201',
 | 
				
			||||||
| 
						 | 
					@ -118,12 +117,12 @@ test('Karl-Theodor-Straße to Hofbräuhaus', co(function*(t) {
 | 
				
			||||||
		latitude: 48.137739,
 | 
							latitude: 48.137739,
 | 
				
			||||||
		longitude: 11.579823
 | 
							longitude: 11.579823
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(karlTheodorStr, hofbraeuhaus, {
 | 
						const journeys = await client.journeys(karlTheodorStr, hofbraeuhaus, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -131,13 +130,13 @@ test('Karl-Theodor-Straße to Hofbräuhaus', co(function*(t) {
 | 
				
			||||||
		to: hofbraeuhaus
 | 
							to: hofbraeuhaus
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: via works – with detour
 | 
					// todo: via works – with detour
 | 
				
			||||||
// todo: without detour
 | 
					// todo: without detour
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys', co(function* (t) {
 | 
					test('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -147,10 +146,10 @@ test('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -160,39 +159,39 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(mittersendling, karlTheodorStr, {
 | 
						const journeys = await client.journeys(mittersendling, karlTheodorStr, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs.find(leg => leg.line)
 | 
						const p = journeys[0].legs.find(leg => leg.line)
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Karl-Theodor-Straße', co(function*(t) {
 | 
					test('departures at Karl-Theodor-Straße', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(karlTheodorStr, {
 | 
						const departures = await client.departures(karlTheodorStr, {
 | 
				
			||||||
		duration: 10, when,
 | 
							duration: 10, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: karlTheodorStr
 | 
							id: karlTheodorStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: mittersendling,
 | 
							id: mittersendling,
 | 
				
			||||||
		name: 'Mittersendling',
 | 
							name: 'Mittersendling',
 | 
				
			||||||
| 
						 | 
					@ -205,28 +204,28 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals at Karl-Theodor-Straße', co(function*(t) {
 | 
					test('arrivals at Karl-Theodor-Straße', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(karlTheodorStr, {
 | 
						const arrivals = await client.arrivals(karlTheodorStr, {
 | 
				
			||||||
		duration: 10, when,
 | 
							duration: 10, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: karlTheodorStr
 | 
							id: karlTheodorStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: nearby
 | 
					// todo: nearby
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations named "Nationaltheater"', co(function*(t) {
 | 
					test('locations named "Nationaltheater"', async (t) => {
 | 
				
			||||||
	const nationaltheater = '624639'
 | 
						const nationaltheater = '624639'
 | 
				
			||||||
	const locations = yield client.locations('Nationaltheater', {
 | 
						const locations = await client.locations('Nationaltheater', {
 | 
				
			||||||
		results: 10
 | 
							results: 10
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -240,19 +239,19 @@ test('locations named "Nationaltheater"', co(function*(t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station Karl-Theodor-Straße', co(function* (t) {
 | 
					test('station Karl-Theodor-Straße', async (t) => {
 | 
				
			||||||
	const s = yield client.station(karlTheodorStr)
 | 
						const s = await client.station(karlTheodorStr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, karlTheodorStr)
 | 
						t.equal(s.id, karlTheodorStr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 48.145121,
 | 
							north: 48.145121,
 | 
				
			||||||
		west: 11.543736,
 | 
							west: 11.543736,
 | 
				
			||||||
		south: 48.138339,
 | 
							south: 48.138339,
 | 
				
			||||||
| 
						 | 
					@ -263,10 +262,10 @@ test('radar', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: poetschnerstr,
 | 
							address: poetschnerstr,
 | 
				
			||||||
| 
						 | 
					@ -275,4 +274,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										129
									
								
								test/vbb.js
									
										
									
									
									
								
							
							
						
						
									
										129
									
								
								test/vbb.js
									
										
									
									
									
								
							| 
						 | 
					@ -3,7 +3,6 @@
 | 
				
			||||||
const tapePromise = require('tape-promise').default
 | 
					const tapePromise = require('tape-promise').default
 | 
				
			||||||
const tape = require('tape')
 | 
					const tape = require('tape')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const vbbProfile = require('../p/vbb')
 | 
					const vbbProfile = require('../p/vbb')
 | 
				
			||||||
const products = require('../p/vbb/products')
 | 
					const products = require('../p/vbb/products')
 | 
				
			||||||
| 
						 | 
					@ -49,8 +48,8 @@ const westhafen = '900000001201'
 | 
				
			||||||
const wedding = '900000009104'
 | 
					const wedding = '900000009104'
 | 
				
			||||||
const württembergallee = '900000026153'
 | 
					const württembergallee = '900000026153'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) {
 | 
					test('journeys – Spichernstr. to Bismarckstr.', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys({
 | 
						const journeys = await client.journeys({
 | 
				
			||||||
		type: 'stop',
 | 
							type: 'stop',
 | 
				
			||||||
		id: spichernstr,
 | 
							id: spichernstr,
 | 
				
			||||||
		name: 'U Spichernstr.'
 | 
							name: 'U Spichernstr.'
 | 
				
			||||||
| 
						 | 
					@ -60,7 +59,7 @@ test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) {
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -70,10 +69,10 @@ test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) {
 | 
				
			||||||
	// todo: find a journey where there ticket info is always available
 | 
						// todo: find a journey where there ticket info is always available
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – only subway', co(function* (t) {
 | 
					test('journeys – only subway', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, bismarckstr, {
 | 
						const journeys = await client.journeys(spichernstr, bismarckstr, {
 | 
				
			||||||
		results: 20,
 | 
							results: 20,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		products: {
 | 
							products: {
 | 
				
			||||||
| 
						 | 
					@ -104,7 +103,7 @@ test('journeys – only subway', co(function* (t) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys – with arrival time
 | 
					// todo: journeys – with arrival time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -120,8 +119,8 @@ test('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('earlier/later journeys', co(function* (t) {
 | 
					test('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -131,10 +130,10 @@ test('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('refreshJourney', co(function* (t) {
 | 
					test('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -144,35 +143,35 @@ test('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('trip details', co(function* (t) {
 | 
					test('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, amrumerStr, {
 | 
						const journeys = await client.journeys(spichernstr, amrumerStr, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = journeys[0].legs[0]
 | 
				
			||||||
	t.ok(p.id, 'precondition failed')
 | 
						t.ok(p.id, 'precondition failed')
 | 
				
			||||||
	t.ok(p.line.name, 'precondition failed')
 | 
						t.ok(p.line.name, 'precondition failed')
 | 
				
			||||||
	const trip = yield client.trip(p.id, p.line.name, {when})
 | 
						const trip = await client.trip(p.id, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – station to address', co(function* (t) {
 | 
					test('journeys – station to address', async (t) => {
 | 
				
			||||||
	const torfstr = {
 | 
						const torfstr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
							address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
				
			||||||
		latitude: 52.541797,
 | 
							latitude: 52.541797,
 | 
				
			||||||
		longitude: 13.350042
 | 
							longitude: 13.350042
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, torfstr, {
 | 
						const journeys = await client.journeys(spichernstr, torfstr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -180,9 +179,9 @@ test('journeys – station to address', co(function* (t) {
 | 
				
			||||||
		to: torfstr
 | 
							to: torfstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys – station to POI', co(function* (t) {
 | 
					test('journeys – station to POI', async (t) => {
 | 
				
			||||||
	const atze = {
 | 
						const atze = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '900980720',
 | 
							id: '900980720',
 | 
				
			||||||
| 
						 | 
					@ -190,12 +189,12 @@ test('journeys – station to POI', co(function* (t) {
 | 
				
			||||||
		latitude: 52.543333,
 | 
							latitude: 52.543333,
 | 
				
			||||||
		longitude: 13.351686
 | 
							longitude: 13.351686
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(spichernstr, atze, {
 | 
						const journeys = await client.journeys(spichernstr, atze, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -203,46 +202,46 @@ test('journeys – station to POI', co(function* (t) {
 | 
				
			||||||
		to: atze
 | 
							to: atze
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('journeys: via works – with detour', co(function* (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 = yield client.journeys(westhafen, wedding, {
 | 
						const journeys = await client.journeys(westhafen, wedding, {
 | 
				
			||||||
		via: württembergallee,
 | 
							via: württembergallee,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [württembergallee]
 | 
							detourIds: [württembergallee]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: without detour test
 | 
					// todo: without detour test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures', co(function* (t) {
 | 
					test('departures', async (t) => {
 | 
				
			||||||
	const departures = yield client.departures(spichernstr, {
 | 
						const departures = await client.departures(spichernstr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: spichernstr
 | 
							id: spichernstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures with station object', co(function* (t) {
 | 
					test('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: spichernstr,
 | 
							id: spichernstr,
 | 
				
			||||||
		name: 'U Spichernstr',
 | 
							name: 'U Spichernstr',
 | 
				
			||||||
| 
						 | 
					@ -255,10 +254,10 @@ test('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at Spichernstr. in direction of Westhafen', co(function* (t) {
 | 
					test('departures at Spichernstr. in direction of Westhafen', async (t) => {
 | 
				
			||||||
	yield testDeparturesInDirection({
 | 
						await testDeparturesInDirection({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		fetchTrip: client.trip,
 | 
							fetchTrip: client.trip,
 | 
				
			||||||
| 
						 | 
					@ -268,17 +267,17 @@ test('departures at Spichernstr. in direction of Westhafen', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures at 7-digit station', co(function* (t) {
 | 
					test('departures at 7-digit station', async (t) => {
 | 
				
			||||||
	const eisenach = '8010097' // see derhuerst/vbb-hafas#22
 | 
						const eisenach = '8010097' // see derhuerst/vbb-hafas#22
 | 
				
			||||||
	yield client.departures(eisenach, {when})
 | 
						await client.departures(eisenach, {when})
 | 
				
			||||||
	t.pass('did not fail')
 | 
						t.pass('did not fail')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures without related stations', co(function* (t) {
 | 
					test('departures without related stations', async (t) => {
 | 
				
			||||||
	yield testDeparturesWithoutRelatedStations({
 | 
						await testDeparturesWithoutRelatedStations({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchDepartures: client.departures,
 | 
							fetchDepartures: client.departures,
 | 
				
			||||||
		id: '900000024101', // Charlottenburg
 | 
							id: '900000024101', // Charlottenburg
 | 
				
			||||||
| 
						 | 
					@ -287,29 +286,29 @@ test('departures without related stations', co(function* (t) {
 | 
				
			||||||
		linesOfRelatedStations: ['U7']
 | 
							linesOfRelatedStations: ['U7']
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('arrivals', co(function* (t) {
 | 
					test('arrivals', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(spichernstr, {
 | 
						const arrivals = await client.arrivals(spichernstr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: spichernstr
 | 
							id: spichernstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('nearby', co(function* (t) {
 | 
					test('nearby', async (t) => {
 | 
				
			||||||
	const berlinerStr = '900000044201'
 | 
						const berlinerStr = '900000044201'
 | 
				
			||||||
	const landhausstr = '900000043252'
 | 
						const landhausstr = '900000043252'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Berliner Str./Bundesallee
 | 
						// Berliner Str./Bundesallee
 | 
				
			||||||
	const nearby = yield client.nearby({
 | 
						const nearby = await client.nearby({
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		latitude: 52.4873452,
 | 
							latitude: 52.4873452,
 | 
				
			||||||
		longitude: 13.3310411
 | 
							longitude: 13.3310411
 | 
				
			||||||
| 
						 | 
					@ -328,10 +327,10 @@ test('nearby', co(function* (t) {
 | 
				
			||||||
	t.ok(nearby[1].distance < 200)
 | 
						t.ok(nearby[1].distance < 200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('locations', co(function* (t) {
 | 
					test('locations', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Alexanderplatz', {results: 20})
 | 
						const locations = await client.locations('Alexanderplatz', {results: 20})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, locations, 'locations', 'locations')
 | 
						validate(t, locations, 'locations', 'locations')
 | 
				
			||||||
	t.ok(locations.length <= 20)
 | 
						t.ok(locations.length <= 20)
 | 
				
			||||||
| 
						 | 
					@ -341,19 +340,19 @@ test('locations', co(function* (t) {
 | 
				
			||||||
	t.ok(locations.find(s => !s.name && s.address)) // addresses
 | 
						t.ok(locations.find(s => !s.name && s.address)) // addresses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('station', co(function* (t) {
 | 
					test('station', async (t) => {
 | 
				
			||||||
	const s = yield client.station(spichernstr)
 | 
						const s = await client.station(spichernstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, spichernstr)
 | 
						t.equal(s.id, spichernstr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('radar', co(function* (t) {
 | 
					test('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 52.52411,
 | 
							north: 52.52411,
 | 
				
			||||||
		west: 13.41002,
 | 
							west: 13.41002,
 | 
				
			||||||
		south: 52.51942,
 | 
							south: 52.51942,
 | 
				
			||||||
| 
						 | 
					@ -364,9 +363,9 @@ test('radar', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('reachableFrom', co(function* (t) {
 | 
					test('reachableFrom', async (t) => {
 | 
				
			||||||
	const torfstr17 = {
 | 
						const torfstr17 = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
							address: '13353 Berlin-Wedding, Torfstr. 17',
 | 
				
			||||||
| 
						 | 
					@ -374,7 +373,7 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		longitude: 13.350042
 | 
							longitude: 13.350042
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testReachableFrom({
 | 
						await testReachableFrom({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		reachableFrom: client.reachableFrom,
 | 
							reachableFrom: client.reachableFrom,
 | 
				
			||||||
		address: torfstr17,
 | 
							address: torfstr17,
 | 
				
			||||||
| 
						 | 
					@ -383,4 +382,4 @@ test('reachableFrom', co(function* (t) {
 | 
				
			||||||
		validate
 | 
							validate
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										99
									
								
								test/vbn.js
									
										
									
									
									
								
							
							
						
						
									
										99
									
								
								test/vbn.js
									
										
									
									
									
								
							| 
						 | 
					@ -5,7 +5,6 @@ const tape = require('tape')
 | 
				
			||||||
const isRoughlyEqual = require('is-roughly-equal')
 | 
					const isRoughlyEqual = require('is-roughly-equal')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {createWhen} = require('./lib/util')
 | 
					const {createWhen} = require('./lib/util')
 | 
				
			||||||
const co = require('./lib/co')
 | 
					 | 
				
			||||||
const createClient = require('..')
 | 
					const createClient = require('..')
 | 
				
			||||||
const vbnProfile = require('../p/vbn')
 | 
					const vbnProfile = require('../p/vbn')
 | 
				
			||||||
const products = require('../p/vbn/products')
 | 
					const products = require('../p/vbn/products')
 | 
				
			||||||
| 
						 | 
					@ -40,14 +39,14 @@ const client = createClient(vbnProfile, 'public-transport/hafas-client:test')
 | 
				
			||||||
const bremenHbf = '8000050'
 | 
					const bremenHbf = '8000050'
 | 
				
			||||||
const bremerhavenHbf = '8000051'
 | 
					const bremerhavenHbf = '8000051'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.only('journeys – Bremen Hbf to Bremerhaven Hbf', co(function* (t) {
 | 
					test.only('journeys – Bremen Hbf to Bremerhaven Hbf', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(bremenHbf, bremerhavenHbf, {
 | 
						const journeys = await client.journeys(bremenHbf, bremerhavenHbf, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToStation({
 | 
						await testJourneysStationToStation({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -55,7 +54,7 @@ test.only('journeys – Bremen Hbf to Bremerhaven Hbf', co(function* (t) {
 | 
				
			||||||
		toId: bremerhavenHbf
 | 
							toId: bremerhavenHbf
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: journeys, only one product
 | 
					// todo: journeys, only one product
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +70,7 @@ test.skip('journeys – fails with no product', (t) => {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
					test.skip('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', async (t) => {
 | 
				
			||||||
	const sternStr = {
 | 
						const sternStr = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		address: 'Magdeburg - Altenstadt, Sternstraße 10',
 | 
							address: 'Magdeburg - Altenstadt, Sternstraße 10',
 | 
				
			||||||
| 
						 | 
					@ -79,12 +78,12 @@ test.skip('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
				
			||||||
		longitude: 11.422332
 | 
							longitude: 11.422332
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const journeys = yield client.journeys(bremenHbf, sternStr, {
 | 
						const journeys = await client.journeys(bremenHbf, sternStr, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToAddress({
 | 
						await testJourneysStationToAddress({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -92,9 +91,9 @@ test.skip('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
 | 
				
			||||||
		to: sternStr
 | 
							to: sternStr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
					test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', async (t) => {
 | 
				
			||||||
	const kloster = {
 | 
						const kloster = {
 | 
				
			||||||
		type: 'location',
 | 
							type: 'location',
 | 
				
			||||||
		id: '970012223',
 | 
							id: '970012223',
 | 
				
			||||||
| 
						 | 
					@ -102,12 +101,12 @@ test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
				
			||||||
		latitude: 52.127601,
 | 
							latitude: 52.127601,
 | 
				
			||||||
		longitude: 11.636437
 | 
							longitude: 11.636437
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const journeys = yield client.journeys(bremenHbf, kloster, {
 | 
						const journeys = await client.journeys(bremenHbf, kloster, {
 | 
				
			||||||
		results: 3,
 | 
							results: 3,
 | 
				
			||||||
		departure: when
 | 
							departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysStationToPoi({
 | 
						await testJourneysStationToPoi({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -115,32 +114,32 @@ test.skip('Magdeburg Hbf to Kloster Unser Lieben Frauen', co(function*(t) {
 | 
				
			||||||
		to: kloster
 | 
							to: kloster
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('journeys: via works – with detour', co(function* (t) {
 | 
					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 = yield client.journeys(hasselbachplatzSternstrasse, stendal, {
 | 
						const journeys = await client.journeys(hasselbachplatzSternstrasse, stendal, {
 | 
				
			||||||
		via: dessau,
 | 
							via: dessau,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		departure: when,
 | 
							departure: when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testJourneysWithDetour({
 | 
						await testJourneysWithDetour({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		journeys,
 | 
							journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		detourIds: [dessau]
 | 
							detourIds: [dessau]
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: without detour
 | 
					// todo: without detour
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('earlier/later journeys', co(function* (t) {
 | 
					test.skip('earlier/later journeys', async (t) => {
 | 
				
			||||||
	yield testEarlierLaterJourneys({
 | 
						await testEarlierLaterJourneys({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
| 
						 | 
					@ -150,10 +149,10 @@ test.skip('earlier/later journeys', co(function* (t) {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('refreshJourney', co(function* (t) {
 | 
					test.skip('refreshJourney', async (t) => {
 | 
				
			||||||
	yield testRefreshJourney({
 | 
						await testRefreshJourney({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		fetchJourneys: client.journeys,
 | 
							fetchJourneys: client.journeys,
 | 
				
			||||||
		refreshJourney: client.refreshJourney,
 | 
							refreshJourney: client.refreshJourney,
 | 
				
			||||||
| 
						 | 
					@ -163,39 +162,39 @@ test.skip('refreshJourney', co(function* (t) {
 | 
				
			||||||
		when
 | 
							when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('trip details', co(function* (t) {
 | 
					test.skip('trip details', async (t) => {
 | 
				
			||||||
	const journeys = yield client.journeys(bremenHbf, bremerhavenHbf, {
 | 
						const journeys = await client.journeys(bremenHbf, bremerhavenHbf, {
 | 
				
			||||||
		results: 1, departure: when
 | 
							results: 1, departure: when
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const p = journeys[0].legs[0]
 | 
						const p = 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 = yield client.trip(p.tripId, p.line.name, {when})
 | 
						const trip = await client.trip(p.tripId, p.line.name, {when})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, trip, 'journeyLeg', 'trip')
 | 
						validate(t, trip, 'journeyLeg', 'trip')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
test.skip('departures at Magdeburg Leiterstr.', co(function*(t) {
 | 
					 | 
				
			||||||
	const departures = yield client.departures(leiterstr, {
 | 
					 | 
				
			||||||
		duration: 5, when,
 | 
					 | 
				
			||||||
		stopovers: false
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testDepartures({
 | 
					test.skip('departures at Magdeburg Leiterstr.', async (t) => {
 | 
				
			||||||
 | 
						const departures = await client.departures(leiterstr, {
 | 
				
			||||||
 | 
							duration: 5, when,
 | 
				
			||||||
 | 
							stopovers: true
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						await testDepartures({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		departures,
 | 
							departures,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: leiterstr
 | 
							id: leiterstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('departures with station object', co(function* (t) {
 | 
					test.skip('departures with station object', async (t) => {
 | 
				
			||||||
	const deps = yield client.departures({
 | 
						const deps = await client.departures({
 | 
				
			||||||
		type: 'station',
 | 
							type: 'station',
 | 
				
			||||||
		id: bremenHbf,
 | 
							id: bremenHbf,
 | 
				
			||||||
		name: 'Magdeburg Hbf',
 | 
							name: 'Magdeburg Hbf',
 | 
				
			||||||
| 
						 | 
					@ -208,27 +207,27 @@ test.skip('departures with station object', co(function* (t) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, deps, 'departures', 'departures')
 | 
						validate(t, deps, 'departures', 'departures')
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('arrivals at Magdeburg Leiterstr.', co(function*(t) {
 | 
					test.skip('arrivals at Magdeburg Leiterstr.', async (t) => {
 | 
				
			||||||
	const arrivals = yield client.arrivals(leiterstr, {
 | 
						const arrivals = await client.arrivals(leiterstr, {
 | 
				
			||||||
		duration: 5, when,
 | 
							duration: 5, when,
 | 
				
			||||||
		stopovers: true
 | 
							stopovers: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	yield testArrivals({
 | 
						await testArrivals({
 | 
				
			||||||
		test: t,
 | 
							test: t,
 | 
				
			||||||
		arrivals,
 | 
							arrivals,
 | 
				
			||||||
		validate,
 | 
							validate,
 | 
				
			||||||
		id: leiterstr
 | 
							id: leiterstr
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// todo: nearby
 | 
					// todo: nearby
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('locations named Magdeburg', co(function*(t) {
 | 
					test.skip('locations named Magdeburg', async (t) => {
 | 
				
			||||||
	const locations = yield client.locations('Magdeburg', {
 | 
						const locations = await client.locations('Magdeburg', {
 | 
				
			||||||
		results: 20
 | 
							results: 20
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -242,19 +241,19 @@ test.skip('locations named Magdeburg', co(function*(t) {
 | 
				
			||||||
	}))
 | 
						}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('station Magdeburg-Buckau', co(function* (t) {
 | 
					test.skip('station Magdeburg-Buckau', async (t) => {
 | 
				
			||||||
	const s = yield client.station(bremerhavenHbf)
 | 
						const s = await client.station(bremerhavenHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	validate(t, s, ['stop', 'station'], 'station')
 | 
						validate(t, s, ['stop', 'station'], 'station')
 | 
				
			||||||
	t.equal(s.id, bremerhavenHbf)
 | 
						t.equal(s.id, bremerhavenHbf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.skip('radar', co(function* (t) {
 | 
					test.skip('radar', async (t) => {
 | 
				
			||||||
	const vehicles = yield client.radar({
 | 
						const vehicles = await client.radar({
 | 
				
			||||||
		north: 52.148364,
 | 
							north: 52.148364,
 | 
				
			||||||
		west: 11.600826,
 | 
							west: 11.600826,
 | 
				
			||||||
		south: 52.108486,
 | 
							south: 52.108486,
 | 
				
			||||||
| 
						 | 
					@ -270,4 +269,4 @@ test.skip('radar', co(function* (t) {
 | 
				
			||||||
	validate(t, vehicles, 'movements', 'vehicles')
 | 
						validate(t, vehicles, 'movements', 'vehicles')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue