| 
									
										
										
										
											2019-08-19 20:42:19 +02:00
										 |  |  | 'use strict' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const tapePromise = require('tape-promise').default | 
					
						
							|  |  |  | const tape = require('tape') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const createClient = require('..') | 
					
						
							|  |  |  | const rawProfile = require('../p/vbb') | 
					
						
							| 
									
										
										
										
											2019-10-25 23:42:17 +02:00
										 |  |  | const res = require('./fixtures/vbb-departures.json') | 
					
						
							| 
									
										
										
										
											2019-08-19 20:42:19 +02:00
										 |  |  | const expected = require('./fixtures/vbb-departures.js') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const test = tapePromise(tape) | 
					
						
							|  |  |  | const client = createClient(rawProfile, 'public-transport/hafas-client:test') | 
					
						
							|  |  |  | const {profile} = client | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const opt = { | 
					
						
							|  |  |  | 	direction: null, | 
					
						
							|  |  |  | 	duration: 10, | 
					
						
							|  |  |  | 	linesOfStops: true, | 
					
						
							|  |  |  | 	remarks: true, | 
					
						
							|  |  |  | 	stopovers: true, | 
					
						
							|  |  |  | 	includeRelatedStations: true, | 
					
						
							|  |  |  | 	when: '2019-08-19T20:30:00+02:00', | 
					
						
							|  |  |  | 	products: {} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('parses a departure correctly (VBB)', (t) => { | 
					
						
							| 
									
										
										
										
											2019-10-25 23:42:17 +02:00
										 |  |  | 	const common = profile.parseCommon({profile, opt, res}) | 
					
						
							|  |  |  | 	const ctx = {profile, opt, common, res} | 
					
						
							|  |  |  | 	const departures = res.jnyL.map(d => profile.parseDeparture(ctx, d)) | 
					
						
							| 
									
										
										
										
											2019-08-19 20:42:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	t.deepEqual(departures, expected) | 
					
						
							|  |  |  | 	t.end() | 
					
						
							|  |  |  | }) |