2017-11-14 02:50:24 +01:00
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
|
|
const a = require('assert')
|
|
|
|
|
const isRoughlyEqual = require('is-roughly-equal')
|
|
|
|
|
const stations = require('vbb-stations-autocomplete')
|
2017-11-14 02:59:17 +01:00
|
|
|
|
const tapePromise = require('tape-promise').default
|
|
|
|
|
const tape = require('tape')
|
2017-11-29 02:27:31 +01:00
|
|
|
|
const co = require('co')
|
2017-12-11 15:20:50 +01:00
|
|
|
|
const shorten = require('vbb-short-station-name')
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
const createClient = require('..')
|
|
|
|
|
const vbbProfile = require('../p/vbb')
|
|
|
|
|
const {
|
2017-12-11 15:20:50 +01:00
|
|
|
|
assertValidStation: _assertValidStation,
|
2017-11-14 02:50:24 +01:00
|
|
|
|
assertValidPoi,
|
|
|
|
|
assertValidAddress,
|
|
|
|
|
assertValidLocation,
|
2017-12-11 14:51:09 +01:00
|
|
|
|
assertValidLine: _assertValidLine,
|
2017-11-20 15:08:30 +01:00
|
|
|
|
assertValidStopover,
|
2017-12-28 22:57:22 +01:00
|
|
|
|
hour, createWhen,
|
2017-12-12 23:15:06 +01:00
|
|
|
|
assertValidWhen,
|
2017-12-11 15:41:27 +01:00
|
|
|
|
assertValidTicket
|
2017-11-14 02:50:24 +01:00
|
|
|
|
} = require('./util')
|
|
|
|
|
|
2017-12-28 22:57:22 +01:00
|
|
|
|
const when = createWhen('Europe/Berlin', 'de-DE')
|
|
|
|
|
|
2017-12-11 15:20:50 +01:00
|
|
|
|
const assertValidStation = (t, s, coordsOptional = false) => {
|
|
|
|
|
_assertValidStation(t, s, coordsOptional)
|
|
|
|
|
t.equal(s.name, shorten(s.name))
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 14:41:28 +01:00
|
|
|
|
const assertValidStationProducts = (t, p) => {
|
|
|
|
|
t.ok(p)
|
|
|
|
|
t.equal(typeof p.suburban, 'boolean')
|
|
|
|
|
t.equal(typeof p.subway, 'boolean')
|
|
|
|
|
t.equal(typeof p.tram, 'boolean')
|
|
|
|
|
t.equal(typeof p.bus, 'boolean')
|
|
|
|
|
t.equal(typeof p.ferry, 'boolean')
|
|
|
|
|
t.equal(typeof p.express, 'boolean')
|
|
|
|
|
t.equal(typeof p.regional, 'boolean')
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 14:51:09 +01:00
|
|
|
|
const assertValidLine = (t, l) => {
|
|
|
|
|
_assertValidLine(t, l)
|
|
|
|
|
if (l.symbol !== null) t.equal(typeof l.symbol, 'string')
|
|
|
|
|
if (l.nr !== null) t.equal(typeof l.nr, 'number')
|
|
|
|
|
if (l.metro !== null) t.equal(typeof l.metro, 'boolean')
|
|
|
|
|
if (l.express !== null) t.equal(typeof l.express, 'boolean')
|
|
|
|
|
if (l.night !== null) t.equal(typeof l.night, 'boolean')
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
// todo
|
2017-11-14 02:50:24 +01:00
|
|
|
|
const findStation = (query) => stations(query, true, false)
|
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
const test = tapePromise(tape)
|
2017-11-14 02:50:24 +01:00
|
|
|
|
const client = createClient(vbbProfile)
|
|
|
|
|
|
2017-11-20 01:05:48 +01:00
|
|
|
|
const amrumerStr = '900000009101'
|
|
|
|
|
const spichernstr = '900000042101'
|
|
|
|
|
const bismarckstr = '900000024201'
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('journeys – station to station', co.wrap(function* (t) {
|
|
|
|
|
const journeys = yield client.journeys(spichernstr, amrumerStr, {
|
2017-11-14 02:50:24 +01:00
|
|
|
|
results: 3, when, passedStations: true
|
|
|
|
|
})
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(journeys))
|
|
|
|
|
t.strictEqual(journeys.length, 3)
|
|
|
|
|
|
|
|
|
|
for (let journey of journeys) {
|
|
|
|
|
assertValidStation(t, journey.origin)
|
2017-12-11 14:41:28 +01:00
|
|
|
|
assertValidStationProducts(t, journey.origin.products)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(journey.origin.name.indexOf('(Berlin)') === -1)
|
2017-11-20 01:05:48 +01:00
|
|
|
|
t.strictEqual(journey.origin.id, spichernstr)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, journey.departure, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
assertValidStation(t, journey.destination)
|
2017-12-11 14:41:28 +01:00
|
|
|
|
assertValidStationProducts(t, journey.destination.products)
|
2017-11-20 01:05:48 +01:00
|
|
|
|
t.strictEqual(journey.destination.id, amrumerStr)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, journey.arrival, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
t.ok(Array.isArray(journey.legs))
|
|
|
|
|
t.strictEqual(journey.legs.length, 1)
|
|
|
|
|
const leg = journey.legs[0]
|
|
|
|
|
|
|
|
|
|
t.equal(typeof leg.id, 'string')
|
|
|
|
|
t.ok(leg.id)
|
|
|
|
|
assertValidStation(t, leg.origin)
|
|
|
|
|
assertValidStationProducts(t, leg.origin.products)
|
|
|
|
|
t.ok(leg.origin.name.indexOf('(Berlin)') === -1)
|
|
|
|
|
t.strictEqual(leg.origin.id, spichernstr)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.departure, when)
|
2017-12-28 17:14:53 +01:00
|
|
|
|
|
|
|
|
|
assertValidStation(t, leg.destination)
|
|
|
|
|
assertValidStationProducts(t, leg.destination.products)
|
|
|
|
|
t.strictEqual(leg.destination.id, amrumerStr)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.arrival, when)
|
2017-12-28 17:14:53 +01:00
|
|
|
|
|
|
|
|
|
assertValidLine(t, leg.line)
|
|
|
|
|
t.ok(findStation(leg.direction))
|
|
|
|
|
t.ok(leg.direction.indexOf('(Berlin)') === -1)
|
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(leg.passed))
|
|
|
|
|
for (let passed of leg.passed) assertValidStopover(t, passed)
|
2017-12-11 15:41:27 +01:00
|
|
|
|
|
2017-12-11 15:49:58 +01:00
|
|
|
|
// todo: find a journey where there ticket info is always available
|
|
|
|
|
if (journey.tickets) {
|
|
|
|
|
t.ok(Array.isArray(journey.tickets))
|
|
|
|
|
for (let ticket of journey.tickets) assertValidTicket(t, ticket)
|
|
|
|
|
}
|
2017-11-14 02:59:17 +01:00
|
|
|
|
}
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('journeys – only subway', co.wrap(function* (t) {
|
|
|
|
|
const journeys = yield client.journeys(spichernstr, bismarckstr, {
|
2017-11-14 02:50:24 +01:00
|
|
|
|
results: 20, when,
|
|
|
|
|
products: {
|
|
|
|
|
suburban: false,
|
|
|
|
|
subway: true,
|
|
|
|
|
tram: false,
|
|
|
|
|
bus: false,
|
|
|
|
|
ferry: false,
|
|
|
|
|
express: false,
|
|
|
|
|
regional: false
|
|
|
|
|
}
|
|
|
|
|
})
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(journeys))
|
|
|
|
|
t.ok(journeys.length > 1)
|
|
|
|
|
|
|
|
|
|
for (let journey of journeys) {
|
2017-12-28 17:14:53 +01:00
|
|
|
|
for (let leg of journey.legs) {
|
|
|
|
|
if (leg.line) {
|
|
|
|
|
assertValidLine(t, leg.line)
|
|
|
|
|
t.equal(leg.line.mode, 'train')
|
|
|
|
|
t.equal(leg.line.product, 'subway')
|
2017-11-14 02:50:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-14 02:59:17 +01:00
|
|
|
|
}
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('journeys – fails with no product', co.wrap(function* (t) {
|
2017-11-14 02:59:17 +01:00
|
|
|
|
try {
|
2017-11-29 02:27:31 +01:00
|
|
|
|
yield client.journeys(spichernstr, bismarckstr, {
|
2017-11-14 02:59:17 +01:00
|
|
|
|
when,
|
|
|
|
|
products: {
|
|
|
|
|
suburban: false,
|
|
|
|
|
subway: false,
|
|
|
|
|
tram: false,
|
|
|
|
|
bus: false,
|
|
|
|
|
ferry: false,
|
|
|
|
|
express: false,
|
|
|
|
|
regional: false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} catch (err) {
|
2017-11-14 02:50:24 +01:00
|
|
|
|
t.ok(err, 'error thrown')
|
|
|
|
|
t.end()
|
2017-11-14 02:59:17 +01:00
|
|
|
|
}
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
test('journey leg details', co.wrap(function* (t) {
|
2017-11-29 02:27:31 +01:00
|
|
|
|
const journeys = yield client.journeys(spichernstr, amrumerStr, {
|
2017-11-14 02:59:17 +01:00
|
|
|
|
results: 1, when
|
2017-11-14 02:50:24 +01:00
|
|
|
|
})
|
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const p = journeys[0].legs[0]
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(p.id, 'precondition failed')
|
|
|
|
|
t.ok(p.line.name, 'precondition failed')
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
t.equal(typeof leg.id, 'string')
|
|
|
|
|
t.ok(leg.id)
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
assertValidLine(t, leg.line)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
t.equal(typeof leg.direction, 'string')
|
|
|
|
|
t.ok(leg.direction)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
t.ok(Array.isArray(leg.passed))
|
|
|
|
|
for (let passed of leg.passed) assertValidStopover(t, passed)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('journeys – station to address', co.wrap(function* (t) {
|
|
|
|
|
const journeys = yield client.journeys(spichernstr, {
|
2017-12-12 23:24:55 +01:00
|
|
|
|
type: 'location', address: 'Torfstraße 17',
|
2017-11-14 02:50:24 +01:00
|
|
|
|
latitude: 52.5416823, longitude: 13.3491223
|
|
|
|
|
}, {results: 1, when})
|
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(Array.isArray(journeys))
|
|
|
|
|
t.strictEqual(journeys.length, 1)
|
|
|
|
|
const journey = journeys[0]
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const leg = journey.legs[journey.legs.length - 1]
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
assertValidStation(t, leg.origin)
|
|
|
|
|
assertValidStationProducts(t, leg.origin.products)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.departure, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const dest = leg.destination
|
2017-11-14 02:59:17 +01:00
|
|
|
|
assertValidAddress(t, dest)
|
2017-12-11 19:40:46 +01:00
|
|
|
|
t.strictEqual(dest.address, 'Torfstraße 17')
|
2017-12-11 19:25:29 +01:00
|
|
|
|
t.ok(isRoughlyEqual(.0001, dest.latitude, 52.5416823))
|
|
|
|
|
t.ok(isRoughlyEqual(.0001, dest.longitude, 13.3491223))
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.arrival, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('journeys – station to POI', co.wrap(function* (t) {
|
|
|
|
|
const journeys = yield client.journeys(spichernstr, {
|
2017-12-12 23:24:55 +01:00
|
|
|
|
type: 'location', id: '9980720', name: 'ATZE Musiktheater',
|
2017-11-14 02:50:24 +01:00
|
|
|
|
latitude: 52.543333, longitude: 13.351686
|
|
|
|
|
}, {results: 1, when})
|
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(Array.isArray(journeys))
|
|
|
|
|
t.strictEqual(journeys.length, 1)
|
|
|
|
|
const journey = journeys[0]
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const leg = journey.legs[journey.legs.length - 1]
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
assertValidStation(t, leg.origin)
|
|
|
|
|
assertValidStationProducts(t, leg.origin.products)
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.departure, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 17:14:53 +01:00
|
|
|
|
const dest = leg.destination
|
2017-11-14 02:59:17 +01:00
|
|
|
|
assertValidPoi(t, dest)
|
|
|
|
|
t.strictEqual(dest.name, 'ATZE Musiktheater')
|
2017-12-11 19:25:29 +01:00
|
|
|
|
t.ok(isRoughlyEqual(.0001, dest.latitude, 52.543333))
|
|
|
|
|
t.ok(isRoughlyEqual(.0001, dest.longitude, 13.351686))
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, leg.arrival, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('departures', co.wrap(function* (t) {
|
|
|
|
|
const deps = yield client.departures(spichernstr, {duration: 5, when})
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(Array.isArray(deps))
|
|
|
|
|
t.deepEqual(deps, deps.sort((a, b) => t.when > b.when))
|
|
|
|
|
for (let dep of deps) {
|
2017-12-11 15:20:50 +01:00
|
|
|
|
t.equal(typeof dep.journeyId, 'string')
|
|
|
|
|
t.ok(dep.journeyId)
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.equal(dep.station.name, 'U Spichernstr.')
|
|
|
|
|
assertValidStation(t, dep.station)
|
2017-12-11 14:41:28 +01:00
|
|
|
|
assertValidStationProducts(t, dep.station.products)
|
2017-11-20 01:05:48 +01:00
|
|
|
|
t.strictEqual(dep.station.id, spichernstr)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
2017-12-28 22:57:22 +01:00
|
|
|
|
assertValidWhen(t, dep.when, when)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(findStation(dep.direction))
|
|
|
|
|
assertValidLine(t, dep.line)
|
|
|
|
|
}
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-12-16 03:20:11 +01:00
|
|
|
|
test('departures at 7-digit station', co.wrap(function* (t) {
|
2017-11-14 02:50:24 +01:00
|
|
|
|
const eisenach = '8010097' // see derhuerst/vbb-hafas#22
|
2017-12-16 03:22:36 +01:00
|
|
|
|
yield client.departures(eisenach, {when})
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.pass('did not fail')
|
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('nearby', co.wrap(function* (t) {
|
2017-11-14 02:59:17 +01:00
|
|
|
|
// Berliner Str./Bundesallee
|
2017-11-29 02:27:31 +01:00
|
|
|
|
const nearby = yield client.nearby(52.4873452, 13.3310411, {distance: 200})
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(Array.isArray(nearby))
|
2017-12-11 19:53:26 +01:00
|
|
|
|
for (let n of nearby) {
|
|
|
|
|
if (n.type === 'station') assertValidStation(t, n)
|
|
|
|
|
else assertValidLocation(t, n, false)
|
|
|
|
|
}
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.equal(nearby[0].id, '900000044201')
|
|
|
|
|
t.equal(nearby[0].name, 'U Berliner Str.')
|
|
|
|
|
t.ok(nearby[0].distance > 0)
|
|
|
|
|
t.ok(nearby[0].distance < 100)
|
|
|
|
|
|
|
|
|
|
t.equal(nearby[1].id, '900000043252')
|
|
|
|
|
t.equal(nearby[1].name, 'Landhausstr.')
|
|
|
|
|
t.ok(nearby[1].distance > 100)
|
|
|
|
|
t.ok(nearby[1].distance < 200)
|
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('locations', co.wrap(function* (t) {
|
|
|
|
|
const locations = yield client.locations('Alexanderplatz', {results: 10})
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(locations))
|
|
|
|
|
t.ok(locations.length > 0)
|
|
|
|
|
t.ok(locations.length <= 10)
|
2017-12-11 19:53:26 +01:00
|
|
|
|
for (let l of locations) {
|
|
|
|
|
if (l.type === 'station') assertValidStation(t, l)
|
|
|
|
|
else assertValidLocation(t, l)
|
|
|
|
|
}
|
|
|
|
|
t.ok(locations.find(s => s.type === 'station'))
|
|
|
|
|
t.ok(locations.find(s => s.id && s.name)) // POIs
|
|
|
|
|
t.ok(locations.find(s => !s.name && s.address)) // addresses
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 02:27:31 +01:00
|
|
|
|
test('radar', co.wrap(function* (t) {
|
|
|
|
|
const vehicles = yield client.radar(52.52411, 13.41002, 52.51942, 13.41709, {
|
2017-11-14 02:59:17 +01:00
|
|
|
|
duration: 5 * 60, when
|
|
|
|
|
})
|
2017-11-14 02:50:24 +01:00
|
|
|
|
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.ok(Array.isArray(vehicles))
|
|
|
|
|
t.ok(vehicles.length > 0)
|
|
|
|
|
for (let v of vehicles) {
|
|
|
|
|
|
|
|
|
|
t.ok(findStation(v.direction))
|
|
|
|
|
assertValidLine(t, v.line)
|
|
|
|
|
|
2017-12-11 19:25:29 +01:00
|
|
|
|
t.equal(typeof v.location.latitude, 'number')
|
|
|
|
|
t.ok(v.location.latitude <= 55, 'vehicle is too far away')
|
|
|
|
|
t.ok(v.location.latitude >= 45, 'vehicle is too far away')
|
|
|
|
|
t.equal(typeof v.location.longitude, 'number')
|
|
|
|
|
t.ok(v.location.longitude >= 9, 'vehicle is too far away')
|
|
|
|
|
t.ok(v.location.longitude <= 15, 'vehicle is too far away')
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(v.nextStops))
|
2017-11-20 17:37:08 +01:00
|
|
|
|
for (let st of v.nextStops) {
|
|
|
|
|
assertValidStopover(t, st, true)
|
|
|
|
|
t.strictEqual(st.station.name.indexOf('(Berlin)'), -1)
|
|
|
|
|
|
|
|
|
|
if (st.arrival) {
|
|
|
|
|
t.equal(typeof st.arrival, 'string')
|
|
|
|
|
const arr = +new Date(st.arrival)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
// note that this can be an ICE train
|
|
|
|
|
t.ok(isRoughlyEqual(14 * hour, +when, arr))
|
|
|
|
|
}
|
2017-11-20 17:37:08 +01:00
|
|
|
|
if (st.departure) {
|
|
|
|
|
t.equal(typeof st.departure, 'string')
|
|
|
|
|
const dep = +new Date(st.departure)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
// note that this can be an ICE train
|
|
|
|
|
t.ok(isRoughlyEqual(14 * hour, +when, dep))
|
2017-11-14 02:50:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-14 02:59:17 +01:00
|
|
|
|
|
|
|
|
|
t.ok(Array.isArray(v.frames))
|
|
|
|
|
for (let f of v.frames) {
|
2017-11-20 17:37:08 +01:00
|
|
|
|
assertValidStation(t, f.origin, true)
|
2017-12-11 14:41:28 +01:00
|
|
|
|
assertValidStationProducts(t, f.origin.products)
|
2017-11-20 17:37:08 +01:00
|
|
|
|
t.strictEqual(f.origin.name.indexOf('(Berlin)'), -1)
|
|
|
|
|
assertValidStation(t, f.destination, true)
|
2017-12-11 14:41:28 +01:00
|
|
|
|
assertValidStationProducts(t, f.destination.products)
|
2017-11-20 17:37:08 +01:00
|
|
|
|
t.strictEqual(f.destination.name.indexOf('(Berlin)'), -1)
|
2017-11-14 02:59:17 +01:00
|
|
|
|
t.equal(typeof f.t, 'number')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
t.end()
|
2017-11-29 02:27:31 +01:00
|
|
|
|
}))
|