db-vendo-client/test/e2e/lib/vbb-bvg-validators.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-07-28 13:43:58 +02:00
'use strict'
const a = require('assert')
2019-08-30 18:31:39 +02:00
const products = require('../../../p/bvg/products')
2018-07-28 13:43:58 +02:00
const {createWhen} = require('./util')
const {
station: createValidateStation,
line: createValidateLine,
journeyLeg: createValidateJourneyLeg,
departure: createValidateDeparture,
movement: createValidateMovement
2018-07-28 13:43:58 +02:00
} = require('./validators')
const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01
const when = createWhen('Europe/Berlin', 'de-DE', T_MOCK)
2018-07-28 13:43:58 +02:00
const cfg = {
when,
stationCoordsOptional: false,
products
}
// todo: coordsOptional = false
const validateStation = createValidateStation(cfg)
2018-07-28 13:43:58 +02:00
const _validateLine = createValidateLine(cfg)
const validateLine = (validate, l, name) => {
_validateLine(validate, l, name)
if (l.symbol !== null) {
a.strictEqual(typeof l.symbol, 'string', name + '.symbol must be a string')
a.ok(l.symbol, name + '.symbol must not be empty')
}
if (l.nr !== null) {
a.strictEqual(typeof l.nr, 'number', name + '.nr must be a string')
a.ok(l.nr, name + '.nr must not be empty')
}
if (l.metro !== null) {
a.strictEqual(typeof l.metro, 'boolean', name + '.metro must be a boolean')
}
if (l.express !== null) {
a.strictEqual(typeof l.express, 'boolean', name + '.express must be a boolean')
}
if (l.night !== null) {
a.strictEqual(typeof l.night, 'boolean', name + '.night must be a boolean')
}
}
const validateJourneyLeg = createValidateJourneyLeg(cfg)
2018-07-28 13:43:58 +02:00
const validateDeparture = createValidateDeparture(cfg)
2018-07-28 13:43:58 +02:00
const validateMovement = createValidateMovement(cfg)
2018-07-28 13:43:58 +02:00
module.exports = {
cfg,
validateStation,
validateLine,
validateJourneyLeg,
validateDeparture,
validateMovement
}