mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
VBB/BVG E2E/integration tests: refactor shared test utils ✅
This commit is contained in:
parent
7b0374695a
commit
70ae1b48bc
3 changed files with 51 additions and 39 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue