diff --git a/test/e2e/bvg.js b/test/e2e/bvg.js index 8797e8b4..b44a1e3a 100644 --- a/test/e2e/bvg.js +++ b/test/e2e/bvg.js @@ -7,17 +7,12 @@ const isRoughlyEqual = require('is-roughly-equal') const {DateTime} = require('luxon') const flatMap = require('lodash/flatMap') +const {createWhen} = require('./lib/util') const createClient = require('../..') const bvgProfile = require('../../p/bvg') const products = require('../../p/bvg/products') const createValidate = require('./lib/validate-fptf-with') -const { - cfg, - validateStation, - validateJourneyLeg, - validateDeparture, - validateMovement -} = require('./lib/vbb-bvg-validators') +const createBvgValidators = require('./lib/vbb-bvg-validators') const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToAddress = require('./lib/journeys-station-to-address') const testJourneysStationToPoi = require('./lib/journeys-station-to-poi') @@ -32,7 +27,18 @@ const testArrivals = require('./lib/arrivals') const testJourneysWithDetour = require('./lib/journeys-with-detour') const testReachableFrom = require('./lib/reachable-from') -const when = cfg.when +const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01 +const when = createWhen(bvgProfile.timezone, bvgProfile.locale, T_MOCK) + +const { + cfg, + validateStation, + validateJourneyLeg, + validateDeparture, + validateMovement +} = createBvgValidators({ + when, +}) const validate = createValidate(cfg, { station: validateStation, diff --git a/test/e2e/lib/vbb-bvg-validators.js b/test/e2e/lib/vbb-bvg-validators.js index 05850b41..32962101 100644 --- a/test/e2e/lib/vbb-bvg-validators.js +++ b/test/e2e/lib/vbb-bvg-validators.js @@ -3,7 +3,6 @@ const a = require('assert') const products = require('../../../p/bvg/products') -const {createWhen} = require('./util') const { station: createValidateStation, journeyLeg: createValidateJourneyLeg, @@ -11,28 +10,29 @@ const { movement: createValidateMovement } = require('./validators') -const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01 -const when = createWhen('Europe/Berlin', 'de-DE', T_MOCK) +const createValidators = ({when}) => { + const cfg = { + when, + stationCoordsOptional: false, + products + } -const cfg = { - when, - stationCoordsOptional: false, - products + // todo: coordsOptional = false + const validateStation = createValidateStation(cfg) + + const validateJourneyLeg = createValidateJourneyLeg(cfg) + + const validateDeparture = createValidateDeparture(cfg) + + const validateMovement = createValidateMovement(cfg) + + return { + cfg, + validateStation, + validateJourneyLeg, + validateDeparture, + validateMovement + } } -// todo: coordsOptional = false -const validateStation = createValidateStation(cfg) - -const validateJourneyLeg = createValidateJourneyLeg(cfg) - -const validateDeparture = createValidateDeparture(cfg) - -const validateMovement = createValidateMovement(cfg) - -module.exports = { - cfg, - validateStation, - validateJourneyLeg, - validateDeparture, - validateMovement -} +module.exports = createValidators diff --git a/test/e2e/vbb.js b/test/e2e/vbb.js index 7880bbfc..8e5f6a34 100644 --- a/test/e2e/vbb.js +++ b/test/e2e/vbb.js @@ -2,16 +2,11 @@ const tap = require('tap') +const {createWhen} = require('./lib/util') const createClient = require('../..') const vbbProfile = require('../../p/vbb') const products = require('../../p/vbb/products') -const { - cfg, - validateStation, - validateJourneyLeg, - validateDeparture, - validateMovement -} = require('./lib/vbb-bvg-validators') +const createVbbValidators = require('./lib/vbb-bvg-validators') const createValidate = require('./lib/validate-fptf-with') const testJourneysStationToStation = require('./lib/journeys-station-to-station') const testJourneysStationToAddress = require('./lib/journeys-station-to-address') @@ -26,7 +21,18 @@ const testArrivals = require('./lib/arrivals') const testJourneysWithDetour = require('./lib/journeys-with-detour') const testReachableFrom = require('./lib/reachable-from') -const when = cfg.when +const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01 +const when = createWhen(vbbProfile.timezone, vbbProfile.locale, T_MOCK) + +const { + cfg, + validateStation, + validateJourneyLeg, + validateDeparture, + validateMovement +} = createVbbValidators({ + when, +}) const validate = createValidate(cfg, { station: validateStation,