mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tests: move assertValidStationProducts into assertValidStation
This commit is contained in:
parent
3680f1fe94
commit
41b574c468
5 changed files with 56 additions and 150 deletions
40
test/db.js
40
test/db.js
|
@ -10,7 +10,7 @@ const createClient = require('..')
|
|||
const dbProfile = require('../p/db')
|
||||
const allProducts = require('../p/db/products')
|
||||
const {
|
||||
assertValidStation,
|
||||
assertValidStation: _assertValidStation,
|
||||
assertValidPoi,
|
||||
assertValidAddress,
|
||||
assertValidLocation,
|
||||
|
@ -21,18 +21,15 @@ const {
|
|||
|
||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
||||
const assertValidStationProducts = (t, p) => {
|
||||
t.ok(p)
|
||||
t.equal(typeof p.nationalExp, 'boolean')
|
||||
t.equal(typeof p.national, 'boolean')
|
||||
t.equal(typeof p.regionalExp, 'boolean')
|
||||
t.equal(typeof p.regional, 'boolean')
|
||||
t.equal(typeof p.suburban, 'boolean')
|
||||
t.equal(typeof p.bus, 'boolean')
|
||||
t.equal(typeof p.ferry, 'boolean')
|
||||
t.equal(typeof p.subway, 'boolean')
|
||||
t.equal(typeof p.tram, 'boolean')
|
||||
t.equal(typeof p.taxi, 'boolean')
|
||||
// todo: DRY with other tests, move into lib
|
||||
const assertValidStation = (t, s) => {
|
||||
_assertValidStation(t, s)
|
||||
t.ok(s.products)
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
const msg = `station.products[${product}] must be a boolean`
|
||||
t.equal(typeof s.products[product], 'boolean', msg)
|
||||
}
|
||||
}
|
||||
|
||||
const findStation = (id) => new Promise((yay, nay) => {
|
||||
|
@ -69,15 +66,6 @@ const assertIsJungfernheide = (t, s) => {
|
|||
t.ok(isRoughlyEqual(s.location.longitude, 13.299424, .0005))
|
||||
}
|
||||
|
||||
// todo: DRY with assertValidStationProducts
|
||||
// todo: DRY with other tests
|
||||
const assertValidProducts = (t, p) => {
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
t.equal(typeof p[product], 'boolean', 'product ' + p + ' must be a boolean')
|
||||
}
|
||||
}
|
||||
|
||||
const assertValidPrice = (t, p) => {
|
||||
t.ok(p)
|
||||
if (p.amount !== null) {
|
||||
|
@ -114,7 +102,6 @@ test('Berlin Jungfernheide to München Hbf', co(function* (t) {
|
|||
const leg = journey.legs[0] // todo: all legs
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
if (!(yield findStation(leg.origin.id))) {
|
||||
console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
}
|
||||
|
@ -122,7 +109,6 @@ test('Berlin Jungfernheide to München Hbf', co(function* (t) {
|
|||
t.equal(typeof leg.departurePlatform, 'string')
|
||||
|
||||
assertValidStation(t, leg.destination)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
if (!(yield findStation(leg.destination.id))) {
|
||||
console.error('unknown station', leg.destination.id, leg.destination.name)
|
||||
}
|
||||
|
@ -152,11 +138,9 @@ test('Berlin Jungfernheide to Torfstraße 17', co(function* (t) {
|
|||
const leg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
if (!(yield findStation(leg.origin.id))) {
|
||||
console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
}
|
||||
if (leg.origin.products) assertValidProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
assertValidWhen(t, leg.arrival, when)
|
||||
|
||||
|
@ -181,11 +165,9 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
|
|||
const leg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
if (!(yield findStation(leg.origin.id))) {
|
||||
console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
}
|
||||
if (leg.origin.products) assertValidProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
assertValidWhen(t, leg.arrival, when)
|
||||
|
||||
|
@ -298,11 +280,9 @@ test('departures at Berlin Jungfernheide', co(function* (t) {
|
|||
t.ok(Array.isArray(deps))
|
||||
for (let dep of deps) {
|
||||
assertValidStation(t, dep.station)
|
||||
assertValidStationProducts(t, dep.station.products)
|
||||
if (!(yield findStation(dep.station.id))) {
|
||||
console.error('unknown station', dep.station.id, dep.station.name)
|
||||
}
|
||||
if (dep.station.products) assertValidProducts(t, dep.station.products)
|
||||
assertValidWhen(t, dep.when, when)
|
||||
}
|
||||
|
||||
|
|
43
test/insa.js
43
test/insa.js
|
@ -10,7 +10,7 @@ const createClient = require('..')
|
|||
const insaProfile = require('../p/insa')
|
||||
const allProducts = require('../p/insa/products')
|
||||
const {
|
||||
assertValidStation,
|
||||
assertValidStation: _assertValidStation,
|
||||
assertValidPoi,
|
||||
assertValidAddress,
|
||||
assertValidLocation,
|
||||
|
@ -23,15 +23,15 @@ const {
|
|||
|
||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
||||
const assertValidStationProducts = (t, p) => {
|
||||
t.ok(p)
|
||||
t.equal(typeof p.nationalExp, 'boolean')
|
||||
t.equal(typeof p.national, 'boolean')
|
||||
t.equal(typeof p.regional, 'boolean')
|
||||
t.equal(typeof p.suburban, 'boolean')
|
||||
t.equal(typeof p.tram, 'boolean')
|
||||
t.equal(typeof p.bus, 'boolean')
|
||||
t.equal(typeof p.tourismTrain, 'boolean')
|
||||
// todo: DRY with other tests, move into lib
|
||||
const assertValidStation = (t, s, coordsOptional = false) => {
|
||||
_assertValidStation(t, s, coordsOptional)
|
||||
t.ok(s.products)
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
const msg = `station.products[${product}] must be a boolean`
|
||||
t.equal(typeof s.products[product], 'boolean', msg)
|
||||
}
|
||||
}
|
||||
|
||||
const isMagdeburgHbf = s => {
|
||||
|
@ -54,15 +54,6 @@ const assertIsMagdeburgHbf = (t, s) => {
|
|||
t.ok(isRoughlyEqual(s.location.longitude, 11.626891, 0.001))
|
||||
}
|
||||
|
||||
// todo: DRY with assertValidStationProducts
|
||||
// todo: DRY with other tests
|
||||
const assertValidProducts = (t, p) => {
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
t.equal(typeof p[product], 'boolean', 'product ' + p + ' must be a boolean')
|
||||
}
|
||||
}
|
||||
|
||||
const test = tapePromise(tape)
|
||||
const client = createClient(insaProfile)
|
||||
|
||||
|
@ -82,12 +73,10 @@ test('Magdeburg Hbf to Magdeburg-Buckau', co(function*(t) {
|
|||
const leg = journey.legs[0] // todo: all legs
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
t.equal(typeof leg.departurePlatform, 'string')
|
||||
|
||||
assertValidStation(t, leg.destination)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.arrival, when)
|
||||
t.equal(typeof leg.arrivalPlatform, 'string')
|
||||
|
||||
|
@ -120,9 +109,6 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
|
|||
const lastLeg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, firstLeg.origin)
|
||||
assertValidStationProducts(t, firstLeg.origin.products)
|
||||
if (firstLeg.origin.products)
|
||||
assertValidProducts(t, firstLeg.origin.products)
|
||||
assertValidWhen(t, firstLeg.departure, when)
|
||||
assertValidWhen(t, firstLeg.arrival, when)
|
||||
assertValidWhen(t, lastLeg.departure, when)
|
||||
|
@ -168,9 +154,6 @@ test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
|
|||
assertValidWhen(t, lastLeg.arrival, when)
|
||||
|
||||
assertValidStation(t, lastLeg.destination)
|
||||
assertValidStationProducts(t, lastLeg.destination.products)
|
||||
if (lastLeg.destination.products)
|
||||
assertValidProducts(t, lastLeg.destination.products)
|
||||
|
||||
t.end()
|
||||
}))
|
||||
|
@ -230,10 +213,6 @@ test('departures at Magdeburg Hbf', co(function*(t) {
|
|||
t.ok(Array.isArray(deps))
|
||||
for (let dep of deps) {
|
||||
assertValidStation(t, dep.station)
|
||||
assertValidStationProducts(t, dep.station.products)
|
||||
if (dep.station.products) {
|
||||
assertValidProducts(t, dep.station.products)
|
||||
}
|
||||
assertValidWhen(t, dep.when, when)
|
||||
}
|
||||
|
||||
|
@ -366,9 +345,7 @@ test('radar', co(function* (t) {
|
|||
// see #28
|
||||
// todo: check if this works by now
|
||||
assertValidStation(t, f.origin, true)
|
||||
assertValidStationProducts(t, f.origin.products)
|
||||
assertValidStation(t, f.destination, true)
|
||||
assertValidStationProducts(t, f.destination.products)
|
||||
t.equal(typeof f.t, 'number')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ const createClient = require('..')
|
|||
const nahshProfile = require('../p/nahsh')
|
||||
const allProducts = require('../p/nahsh/products')
|
||||
const {
|
||||
assertValidStation,
|
||||
assertValidStation: _assertValidStation,
|
||||
assertValidPoi,
|
||||
assertValidAddress,
|
||||
assertValidLocation,
|
||||
|
@ -24,18 +24,15 @@ const {
|
|||
|
||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
||||
const assertValidStationProducts = (t, p) => {
|
||||
t.ok(p)
|
||||
t.equal(typeof p.nationalExp, 'boolean')
|
||||
t.equal(typeof p.national, 'boolean')
|
||||
t.equal(typeof p.interregional, 'boolean')
|
||||
t.equal(typeof p.regional, 'boolean')
|
||||
t.equal(typeof p.suburban, 'boolean')
|
||||
t.equal(typeof p.bus, 'boolean')
|
||||
t.equal(typeof p.ferry, 'boolean')
|
||||
t.equal(typeof p.subway, 'boolean')
|
||||
t.equal(typeof p.tram, 'boolean')
|
||||
t.equal(typeof p.onCall, 'boolean')
|
||||
// todo: DRY with other tests, move into lib
|
||||
const assertValidStation = (t, s, coordsOptional = false) => {
|
||||
_assertValidStation(t, s, coordsOptional)
|
||||
t.ok(s.products)
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
const msg = `station.products[${product}] must be a boolean`
|
||||
t.equal(typeof s.products[product], 'boolean', msg)
|
||||
}
|
||||
}
|
||||
|
||||
const isKielHbf = (s) => {
|
||||
|
@ -56,15 +53,6 @@ const assertIsKielHbf = (t, s) => {
|
|||
t.ok(isRoughlyEqual(s.location.longitude, 10.131976, .0005))
|
||||
}
|
||||
|
||||
// todo: DRY with assertValidStationProducts
|
||||
// todo: DRY with other tests
|
||||
const assertValidProducts = (t, p) => {
|
||||
for (let product of allProducts) {
|
||||
product = product.product // wat
|
||||
t.equal(typeof p[product], 'boolean', 'product ' + p + ' must be a boolean')
|
||||
}
|
||||
}
|
||||
|
||||
const assertValidPrice = (t, p) => {
|
||||
t.ok(p)
|
||||
if (p.amount !== null) {
|
||||
|
@ -113,7 +101,6 @@ test('Kiel Hbf to Flensburg', co(function* (t) {
|
|||
const leg = journey.legs[0] // todo: all legs
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.origin.id))) {
|
||||
// console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
|
@ -122,7 +109,6 @@ test('Kiel Hbf to Flensburg', co(function* (t) {
|
|||
t.equal(typeof leg.departurePlatform, 'string')
|
||||
|
||||
assertValidStation(t, leg.destination)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.destination.id))) {
|
||||
// console.error('unknown station', leg.destination.id, leg.destination.name)
|
||||
|
@ -158,12 +144,10 @@ test('Kiel Hbf to Husum, Zingel 10', co(function* (t) {
|
|||
const lastLeg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, firstLeg.origin)
|
||||
assertValidStationProducts(t, firstLeg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.origin.id))) {
|
||||
// console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
// }
|
||||
if (firstLeg.origin.products) assertValidProducts(t, firstLeg.origin.products)
|
||||
assertValidWhen(t, firstLeg.departure, when)
|
||||
assertValidWhen(t, firstLeg.arrival, when)
|
||||
assertValidWhen(t, lastLeg.departure, when)
|
||||
|
@ -206,8 +190,6 @@ test('Holstentor to Kiel Hbf', co(function* (t) {
|
|||
assertValidWhen(t, lastLeg.arrival, when)
|
||||
|
||||
assertValidStation(t, lastLeg.destination)
|
||||
assertValidStationProducts(t, lastLeg.destination.products)
|
||||
if (lastLeg.destination.products) assertValidProducts(t, lastLeg.destination.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.destination.id))) {
|
||||
// console.error('unknown station', leg.destination.id, leg.destination.name)
|
||||
|
@ -315,12 +297,10 @@ test('departures at Kiel Hbf', co(function* (t) {
|
|||
t.ok(Array.isArray(deps))
|
||||
for (let dep of deps) {
|
||||
assertValidStation(t, dep.station)
|
||||
assertValidStationProducts(t, dep.station.products)
|
||||
// todo
|
||||
// if (!(yield findStation(dep.station.id))) {
|
||||
// console.error('unknown station', dep.station.id, dep.station.name)
|
||||
// }
|
||||
if (dep.station.products) assertValidProducts(t, dep.station.products)
|
||||
assertValidWhen(t, dep.when, when)
|
||||
}
|
||||
|
||||
|
@ -420,9 +400,7 @@ test.skip('radar Kiel', co(function* (t) {
|
|||
t.ok(Array.isArray(v.frames))
|
||||
for (let f of v.frames) {
|
||||
assertValidStation(t, f.origin, true)
|
||||
assertValidStationProducts(t, f.origin.products)
|
||||
assertValidStation(t, f.destination, true)
|
||||
assertValidStationProducts(t, f.destination.products)
|
||||
t.equal(typeof f.t, 'number')
|
||||
}
|
||||
}
|
||||
|
|
55
test/oebb.js
55
test/oebb.js
|
@ -14,7 +14,7 @@ const createClient = require('..')
|
|||
const oebbProfile = require('../p/oebb')
|
||||
const allProducts = require('../p/oebb/products')
|
||||
const {
|
||||
assertValidStation,
|
||||
assertValidStation: _assertValidStation,
|
||||
assertValidPoi,
|
||||
assertValidAddress,
|
||||
assertValidLocation,
|
||||
|
@ -24,18 +24,17 @@ const {
|
|||
|
||||
const when = createWhen('Europe/Vienna', 'de-AT')
|
||||
|
||||
const assertValidStationProducts = (t, p) => {
|
||||
t.ok(p)
|
||||
t.equal(typeof p.nationalExp, 'boolean')
|
||||
t.equal(typeof p.national, 'boolean')
|
||||
t.equal(typeof p.interregional, 'boolean')
|
||||
t.equal(typeof p.regional, 'boolean')
|
||||
t.equal(typeof p.suburban, 'boolean')
|
||||
t.equal(typeof p.bus, 'boolean')
|
||||
t.equal(typeof p.ferry, 'boolean')
|
||||
t.equal(typeof p.subway, 'boolean')
|
||||
t.equal(typeof p.tram, 'boolean')
|
||||
t.equal(typeof p.onCall, 'boolean')
|
||||
// todo: DRY with other tests, move into lib
|
||||
const assertValidStation = (t, s, coordsOptional = false, productsOptional = false) => {
|
||||
_assertValidStation(t, s, coordsOptional)
|
||||
if (s.products || !productsOptional) {
|
||||
t.ok(s.products)
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
const msg = `station.products[${product}] must be a boolean`
|
||||
t.equal(typeof s.products[product], 'boolean', msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo
|
||||
|
@ -73,15 +72,6 @@ const assertIsSalzburgHbf = (t, s) => {
|
|||
t.ok(isRoughlyEqual(s.location.longitude, 13.045604, .0005))
|
||||
}
|
||||
|
||||
// todo: DRY with assertValidStationProducts
|
||||
// todo: DRY with other tests
|
||||
const assertValidProducts = (t, p) => {
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
t.equal(typeof p[product], 'boolean', 'product ' + p + ' must be a boolean')
|
||||
}
|
||||
}
|
||||
|
||||
const assertValidPrice = (t, p) => {
|
||||
t.ok(p)
|
||||
if (p.amount !== null) {
|
||||
|
@ -133,7 +123,6 @@ test('Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
|
|||
const leg = journey.legs[0] // todo: all legs
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.origin.id))) {
|
||||
// console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
|
@ -142,7 +131,6 @@ test('Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
|
|||
t.equal(typeof leg.departurePlatform, 'string')
|
||||
|
||||
assertValidStation(t, leg.destination)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.destination.id))) {
|
||||
// console.error('unknown station', leg.destination.id, leg.destination.name)
|
||||
|
@ -178,12 +166,10 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
|
|||
const lastLeg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, firstLeg.origin)
|
||||
assertValidStationProducts(t, firstLeg.origin.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.origin.id))) {
|
||||
// console.error('unknown station', leg.origin.id, leg.origin.name)
|
||||
// }
|
||||
if (firstLeg.origin.products) assertValidProducts(t, firstLeg.origin.products)
|
||||
assertValidWhen(t, firstLeg.departure, when)
|
||||
assertValidWhen(t, firstLeg.arrival, when)
|
||||
assertValidWhen(t, lastLeg.departure, when)
|
||||
|
@ -226,8 +212,6 @@ test('Albertina to Salzburg Hbf', co(function* (t) {
|
|||
assertValidWhen(t, lastLeg.arrival, when)
|
||||
|
||||
assertValidStation(t, lastLeg.destination)
|
||||
assertValidStationProducts(t, lastLeg.destination.products)
|
||||
if (lastLeg.destination.products) assertValidProducts(t, lastLeg.destination.products)
|
||||
// todo
|
||||
// if (!(yield findStation(leg.destination.id))) {
|
||||
// console.error('unknown station', leg.destination.id, leg.destination.name)
|
||||
|
@ -363,12 +347,10 @@ test('departures at Salzburg Hbf', co(function* (t) {
|
|||
t.ok(Array.isArray(deps))
|
||||
for (let dep of deps) {
|
||||
assertValidStation(t, dep.station)
|
||||
assertValidStationProducts(t, dep.station.products)
|
||||
// todo
|
||||
// if (!(yield findStation(dep.station.id))) {
|
||||
// console.error('unknown station', dep.station.id, dep.station.name)
|
||||
// }
|
||||
if (dep.station.products) assertValidProducts(t, dep.station.products)
|
||||
assertValidWhen(t, dep.when, when)
|
||||
}
|
||||
|
||||
|
@ -421,7 +403,8 @@ test('locations named Salzburg', co(function* (t) {
|
|||
test('location', co(function* (t) {
|
||||
const loc = yield client.location(grazHbf)
|
||||
|
||||
assertValidStation(t, loc)
|
||||
// todo: find a way to always get products from the API
|
||||
assertValidStation(t, loc, false, true)
|
||||
t.equal(loc.id, grazHbf)
|
||||
|
||||
t.end()
|
||||
|
@ -471,12 +454,10 @@ test('radar Salzburg', co(function* (t) {
|
|||
|
||||
t.ok(Array.isArray(v.frames))
|
||||
for (let f of v.frames) {
|
||||
assertValidStation(t, f.origin, true)
|
||||
// can contain stations in germany which don't have a products property, would break
|
||||
// assertValidStationProducts(t, f.origin.products)
|
||||
assertValidStation(t, f.destination, true)
|
||||
// can contain stations in germany which don't have a products property, would break
|
||||
// assertValidStationProducts(t, f.destination.products)
|
||||
// there are stations which the API desn't return products for
|
||||
// todo: find a way to always get products from the API
|
||||
assertValidStation(t, f.origin, true, true)
|
||||
assertValidStation(t, f.destination, true, true)
|
||||
t.equal(typeof f.t, 'number')
|
||||
}
|
||||
}
|
||||
|
|
24
test/vbb.js
24
test/vbb.js
|
@ -10,6 +10,7 @@ const shorten = require('vbb-short-station-name')
|
|||
const co = require('./co')
|
||||
const createClient = require('..')
|
||||
const vbbProfile = require('../p/vbb')
|
||||
const allProducts = require('../p/vbb/products')
|
||||
const {
|
||||
assertValidStation: _assertValidStation,
|
||||
assertValidPoi,
|
||||
|
@ -24,20 +25,16 @@ const {
|
|||
|
||||
const when = createWhen('Europe/Berlin', 'de-DE')
|
||||
|
||||
// todo: DRY with other tests, move into lib
|
||||
const assertValidStation = (t, s, coordsOptional = false) => {
|
||||
_assertValidStation(t, s, coordsOptional)
|
||||
t.equal(s.name, shorten(s.name))
|
||||
t.ok(s.products)
|
||||
for (let product of allProducts) {
|
||||
product = product.id
|
||||
const msg = `station.products[${product}] must be a boolean`
|
||||
t.equal(typeof s.products[product], 'boolean', msg)
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
const assertValidLine = (t, l) => {
|
||||
|
@ -76,13 +73,11 @@ test('journeys – station to station', co(function* (t) {
|
|||
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)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
|
||||
assertValidStation(t, leg.destination)
|
||||
assertValidStationProducts(t, leg.destination.products)
|
||||
t.strictEqual(leg.destination.id, amrumerStr)
|
||||
assertValidWhen(t, leg.arrival, when)
|
||||
|
||||
|
@ -246,7 +241,6 @@ test('journeys – station to address', co(function* (t) {
|
|||
const leg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
|
||||
const dest = leg.destination
|
||||
|
@ -275,7 +269,6 @@ test('journeys – station to POI', co(function* (t) {
|
|||
const leg = journey.legs[journey.legs.length - 1]
|
||||
|
||||
assertValidStation(t, leg.origin)
|
||||
assertValidStationProducts(t, leg.origin.products)
|
||||
assertValidWhen(t, leg.departure, when)
|
||||
|
||||
const dest = leg.destination
|
||||
|
@ -342,7 +335,6 @@ test('departures', co(function* (t) {
|
|||
|
||||
t.equal(dep.station.name, 'U Spichernstr.')
|
||||
assertValidStation(t, dep.station)
|
||||
assertValidStationProducts(t, dep.station.products)
|
||||
t.strictEqual(dep.station.id, spichernstr)
|
||||
|
||||
assertValidWhen(t, dep.when, when)
|
||||
|
@ -494,10 +486,8 @@ test('radar', co(function* (t) {
|
|||
t.ok(Array.isArray(v.frames))
|
||||
for (let f of v.frames) {
|
||||
assertValidStation(t, f.origin, true)
|
||||
assertValidStationProducts(t, f.origin.products)
|
||||
t.strictEqual(f.origin.name.indexOf('(Berlin)'), -1)
|
||||
assertValidStation(t, f.destination, true)
|
||||
assertValidStationProducts(t, f.destination.products)
|
||||
t.strictEqual(f.destination.name.indexOf('(Berlin)'), -1)
|
||||
t.equal(typeof f.t, 'number')
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue