mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09: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 {DateTime} = require('luxon')
|
||||||
const flatMap = require('lodash/flatMap')
|
const flatMap = require('lodash/flatMap')
|
||||||
|
|
||||||
|
const {createWhen} = require('./lib/util')
|
||||||
const createClient = require('../..')
|
const createClient = require('../..')
|
||||||
const bvgProfile = require('../../p/bvg')
|
const bvgProfile = require('../../p/bvg')
|
||||||
const products = require('../../p/bvg/products')
|
const products = require('../../p/bvg/products')
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
const {
|
const createBvgValidators = require('./lib/vbb-bvg-validators')
|
||||||
cfg,
|
|
||||||
validateStation,
|
|
||||||
validateJourneyLeg,
|
|
||||||
validateDeparture,
|
|
||||||
validateMovement
|
|
||||||
} = require('./lib/vbb-bvg-validators')
|
|
||||||
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
|
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
|
||||||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||||
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
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 testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||||
const testReachableFrom = require('./lib/reachable-from')
|
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, {
|
const validate = createValidate(cfg, {
|
||||||
station: validateStation,
|
station: validateStation,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
const a = require('assert')
|
const a = require('assert')
|
||||||
const products = require('../../../p/bvg/products')
|
const products = require('../../../p/bvg/products')
|
||||||
|
|
||||||
const {createWhen} = require('./util')
|
|
||||||
const {
|
const {
|
||||||
station: createValidateStation,
|
station: createValidateStation,
|
||||||
journeyLeg: createValidateJourneyLeg,
|
journeyLeg: createValidateJourneyLeg,
|
||||||
|
@ -11,28 +10,29 @@ const {
|
||||||
movement: createValidateMovement
|
movement: createValidateMovement
|
||||||
} = require('./validators')
|
} = require('./validators')
|
||||||
|
|
||||||
const T_MOCK = 1641897000 * 1000 // 2022-01-11T11:30:00+01
|
const createValidators = ({when}) => {
|
||||||
const when = createWhen('Europe/Berlin', 'de-DE', T_MOCK)
|
const cfg = {
|
||||||
|
|
||||||
const cfg = {
|
|
||||||
when,
|
when,
|
||||||
stationCoordsOptional: false,
|
stationCoordsOptional: false,
|
||||||
products
|
products
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: coordsOptional = false
|
// todo: coordsOptional = false
|
||||||
const validateStation = createValidateStation(cfg)
|
const validateStation = createValidateStation(cfg)
|
||||||
|
|
||||||
const validateJourneyLeg = createValidateJourneyLeg(cfg)
|
const validateJourneyLeg = createValidateJourneyLeg(cfg)
|
||||||
|
|
||||||
const validateDeparture = createValidateDeparture(cfg)
|
const validateDeparture = createValidateDeparture(cfg)
|
||||||
|
|
||||||
const validateMovement = createValidateMovement(cfg)
|
const validateMovement = createValidateMovement(cfg)
|
||||||
|
|
||||||
module.exports = {
|
return {
|
||||||
cfg,
|
cfg,
|
||||||
validateStation,
|
validateStation,
|
||||||
validateJourneyLeg,
|
validateJourneyLeg,
|
||||||
validateDeparture,
|
validateDeparture,
|
||||||
validateMovement
|
validateMovement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = createValidators
|
||||||
|
|
|
@ -2,16 +2,11 @@
|
||||||
|
|
||||||
const tap = require('tap')
|
const tap = require('tap')
|
||||||
|
|
||||||
|
const {createWhen} = require('./lib/util')
|
||||||
const createClient = require('../..')
|
const createClient = require('../..')
|
||||||
const vbbProfile = require('../../p/vbb')
|
const vbbProfile = require('../../p/vbb')
|
||||||
const products = require('../../p/vbb/products')
|
const products = require('../../p/vbb/products')
|
||||||
const {
|
const createVbbValidators = require('./lib/vbb-bvg-validators')
|
||||||
cfg,
|
|
||||||
validateStation,
|
|
||||||
validateJourneyLeg,
|
|
||||||
validateDeparture,
|
|
||||||
validateMovement
|
|
||||||
} = require('./lib/vbb-bvg-validators')
|
|
||||||
const createValidate = require('./lib/validate-fptf-with')
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
|
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
|
||||||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
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 testJourneysWithDetour = require('./lib/journeys-with-detour')
|
||||||
const testReachableFrom = require('./lib/reachable-from')
|
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, {
|
const validate = createValidate(cfg, {
|
||||||
station: validateStation,
|
station: validateStation,
|
||||||
|
|
Loading…
Add table
Reference in a new issue