mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02:00 
			
		
		
		
	Merge pull request #26 from derhuerst/proper-via-tests
add proper via tests
This commit is contained in:
		
						commit
						afc95ed763
					
				
					 4 changed files with 142 additions and 43 deletions
				
			
		
							
								
								
									
										44
									
								
								test/db.js
									
										
									
									
									
								
							
							
						
						
									
										44
									
								
								test/db.js
									
										
									
									
									
								
							| 
						 | 
					@ -218,18 +218,44 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Berlin Hbf to München Hbf with stopover at Hannover Hbf', co(function* (t) {
 | 
					test('journeys: via works – with detour', co(function* (t) {
 | 
				
			||||||
	const [journey] = yield client.journeys(berlinHbf, münchenHbf, {
 | 
						// Going from Westhafen to Wedding via Württembergalle without detour
 | 
				
			||||||
		via: hannoverHbf,
 | 
						// is currently impossible. We check if the routing engine computes a detour.
 | 
				
			||||||
		results: 1
 | 
						const westhafen = '008089116'
 | 
				
			||||||
 | 
						const wedding = '008089131'
 | 
				
			||||||
 | 
						const württembergallee = '731084'
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(westhafen, wedding, {
 | 
				
			||||||
 | 
							via: württembergallee,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i = journey.legs.findIndex(leg => leg.destination.id === hannoverHbf)
 | 
						t.ok(journey)
 | 
				
			||||||
	t.ok(i >= 0, 'no leg with Hannover Hbf as destination')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const nextLeg = journey.legs[i + 1]
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
 | 
				
			||||||
	t.ok(nextLeg)
 | 
						t.ok(l, 'Württembergalle is not being passed')
 | 
				
			||||||
	t.equal(nextLeg.origin.id, hannoverHbf)
 | 
					
 | 
				
			||||||
 | 
						t.end()
 | 
				
			||||||
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
 | 
						// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
 | 
				
			||||||
 | 
						// to change trains / no need for a "detour".
 | 
				
			||||||
 | 
						const ruhleben = '000731058'
 | 
				
			||||||
 | 
						const zoo = '008010406'
 | 
				
			||||||
 | 
						const kastanienallee = '730983'
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(ruhleben, zoo, {
 | 
				
			||||||
 | 
							via: kastanienallee,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.ok(journey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee))
 | 
				
			||||||
 | 
						t.ok(l, 'Kastanienallee is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										49
									
								
								test/insa.js
									
										
									
									
									
								
							
							
						
						
									
										49
									
								
								test/insa.js
									
										
									
									
									
								
							| 
						 | 
					@ -189,22 +189,47 @@ test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Magdeburg-Buckau to Magdeburg-Neustadt with stopover at Magdeburg Hbf', co(function*(t) {
 | 
					test('journeys: via works – with detour', co(function* (t) {
 | 
				
			||||||
	const magdeburgBuckau = '8013456'
 | 
						// Going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Stendal via Dessau without detour
 | 
				
			||||||
	const magdeburgNeustadt = '8010226'
 | 
						// is currently impossible. We check if the routing engine computes a detour.
 | 
				
			||||||
	const magdeburgHbf = '8010224'
 | 
						const hasselbachplatzSternstrasse = '000006545'
 | 
				
			||||||
	const [journey] = yield client.journeys(magdeburgBuckau, magdeburgNeustadt, {
 | 
						const stendal = '008010334'
 | 
				
			||||||
		via: magdeburgHbf,
 | 
						const dessau = '008010077'
 | 
				
			||||||
 | 
						const dessauPassed = '8010077'
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(hasselbachplatzSternstrasse, stendal, {
 | 
				
			||||||
 | 
							via: dessau,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		when
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i1 = journey.legs.findIndex(leg => leg.destination.id === magdeburgHbf)
 | 
						t.ok(journey)
 | 
				
			||||||
	t.ok(i1 >= 0, 'no leg with Magdeburg Hbf as destination')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i2 = journey.legs.findIndex(leg => leg.origin.id === magdeburgHbf)
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === dessauPassed))
 | 
				
			||||||
	t.ok(i2 >= 0, 'no leg with Magdeburg Hbf as origin')
 | 
						t.ok(l, 'Dessau is not being passed')
 | 
				
			||||||
	t.ok(i2 > i1, 'leg with Magdeburg Hbf as origin must be after leg to it')
 | 
					
 | 
				
			||||||
 | 
						t.end()
 | 
				
			||||||
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
 | 
						// When going from Magdeburg, Hasselbachplatz (Sternstr.) (Tram/Bus) to Magdeburg, Universität via Magdeburg, Breiter Weg, there is *no need*
 | 
				
			||||||
 | 
						// to change trains / no need for a "detour".
 | 
				
			||||||
 | 
						const hasselbachplatzSternstrasse = '000006545'
 | 
				
			||||||
 | 
						const universitaet = '000019686'
 | 
				
			||||||
 | 
						const breiterWeg = '000013519'
 | 
				
			||||||
 | 
						const breiterWegPassed = '13519'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(hasselbachplatzSternstrasse, universitaet, {
 | 
				
			||||||
 | 
							via: breiterWeg,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.ok(journey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === breiterWegPassed))
 | 
				
			||||||
 | 
						t.ok(l, 'Magdeburg, Breiter Weg is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										46
									
								
								test/oebb.js
									
										
									
									
									
								
							
							
						
						
									
										46
									
								
								test/oebb.js
									
										
									
									
									
								
							| 
						 | 
					@ -258,19 +258,47 @@ test('Albertina to Salzburg Hbf', co(function* (t) {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('Wien to Klagenfurt Hbf with stopover at Salzburg Hbf', co(function* (t) {
 | 
					test('journeys: via works – with detour', co(function* (t) {
 | 
				
			||||||
	const [journey] = yield client.journeys(wien, klagenfurtHbf, {
 | 
						// Going from Stephansplatz to Schottenring via Donauinsel without detour
 | 
				
			||||||
		via: salzburgHbf,
 | 
						// is currently impossible. We check if the routing engine computes a detour.
 | 
				
			||||||
 | 
						const stephansplatz = '001390167'
 | 
				
			||||||
 | 
						const schottenring = '001390163'
 | 
				
			||||||
 | 
						const donauinsel = '001392277'
 | 
				
			||||||
 | 
						const donauinselPassed = '922001'
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(stephansplatz, schottenring, {
 | 
				
			||||||
 | 
							via: donauinsel,
 | 
				
			||||||
		results: 1,
 | 
							results: 1,
 | 
				
			||||||
		when
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i1 = journey.legs.findIndex(leg => leg.destination.id === salzburgHbf)
 | 
						t.ok(journey)
 | 
				
			||||||
	t.ok(i1 >= 0, 'no leg with Salzburg Hbf as destination')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i2 = journey.legs.findIndex(leg => leg.origin.id === salzburgHbf)
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === donauinselPassed))
 | 
				
			||||||
	t.ok(i2 >= 0, 'no leg with Salzburg Hbf as origin')
 | 
						t.ok(l, 'Donauinsel is not being passed')
 | 
				
			||||||
	t.ok(i2 > i1, 'leg with Salzburg Hbf as origin must be after leg to it')
 | 
					
 | 
				
			||||||
 | 
						t.end()
 | 
				
			||||||
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
 | 
						// When going from Karlsplatz to Praterstern via Museumsquartier, there is *no need*
 | 
				
			||||||
 | 
						// to change trains / no need for a "detour".
 | 
				
			||||||
 | 
						const karlsplatz = '001390461'
 | 
				
			||||||
 | 
						const praterstern = '001290201'
 | 
				
			||||||
 | 
						const museumsquartier = '001390171'
 | 
				
			||||||
 | 
						const museumsquartierPassed = '901014'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(karlsplatz, praterstern, {
 | 
				
			||||||
 | 
							via: museumsquartier,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.ok(journey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === museumsquartierPassed))
 | 
				
			||||||
 | 
						t.ok(l, 'Weihburggasse is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										46
									
								
								test/vbb.js
									
										
									
									
									
								
							
							
						
						
									
										46
									
								
								test/vbb.js
									
										
									
									
									
								
							| 
						 | 
					@ -300,27 +300,47 @@ test('journeys – station to POI', co(function* (t) {
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('journeys: via works – with detour', co(function* (t) {
 | 
				
			||||||
 | 
						// Going from Westhafen to Wedding via Württembergalle without detour
 | 
				
			||||||
test('journeys – with stopover', co(function* (t) {
 | 
						// is currently impossible. We check if the routing engine computes a detour.
 | 
				
			||||||
	const halleschesTor = '900000012103'
 | 
						const westhafen = '900000001201'
 | 
				
			||||||
	const leopoldplatz = '900000009102'
 | 
						const wedding = '900000009104'
 | 
				
			||||||
	const [journey] = yield client.journeys(spichernstr, halleschesTor, {
 | 
						const württembergallee = '900000026153'
 | 
				
			||||||
		via: leopoldplatz,
 | 
						const [journey] = yield client.journeys(westhafen, wedding, {
 | 
				
			||||||
		results: 1
 | 
							via: württembergallee,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const i = journey.legs.findIndex(leg => leg.destination.id === leopoldplatz)
 | 
						t.ok(journey)
 | 
				
			||||||
	t.ok(i >= 0, 'no leg with Leopoldplatz as destination')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const nextLeg = journey.legs[i + 1]
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
 | 
				
			||||||
	t.ok(nextLeg)
 | 
						t.ok(l, 'Württembergalle is not being passed')
 | 
				
			||||||
	t.equal(nextLeg.origin.id, leopoldplatz)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	t.end()
 | 
						t.end()
 | 
				
			||||||
}))
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('journeys: via works – without detour', co(function* (t) {
 | 
				
			||||||
 | 
						// When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
 | 
				
			||||||
 | 
						// to change trains / no need for a "detour".
 | 
				
			||||||
 | 
						const ruhleben = '900000025202'
 | 
				
			||||||
 | 
						const zoo = '900000023201'
 | 
				
			||||||
 | 
						const kastanienallee = '900000020152'
 | 
				
			||||||
 | 
						const [journey] = yield client.journeys(ruhleben, zoo, {
 | 
				
			||||||
 | 
							via: kastanienallee,
 | 
				
			||||||
 | 
							results: 1,
 | 
				
			||||||
 | 
							when,
 | 
				
			||||||
 | 
							passedStations: true
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.ok(journey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee))
 | 
				
			||||||
 | 
						t.ok(l, 'Kastanienallee is not being passed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.end()
 | 
				
			||||||
 | 
					}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('departures', co(function* (t) {
 | 
					test('departures', co(function* (t) {
 | 
				
			||||||
	const deps = yield client.departures(spichernstr, {duration: 5, when})
 | 
						const deps = yield client.departures(spichernstr, {duration: 5, when})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue