mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
DB: add test for profile.transformJourneysQuery() ✅
This commit is contained in:
parent
45610fc951
commit
a8401f36e1
1 changed files with 83 additions and 0 deletions
83
test/format/db-journeys-query.js
Normal file
83
test/format/db-journeys-query.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
import tap from 'tap'
|
||||
|
||||
import {createClient} from '../../index.js'
|
||||
import {profile as rawProfile} from '../../p/db/index.js'
|
||||
import {data as loyaltyCards} from '../../p/db/loyalty-cards.js'
|
||||
|
||||
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
|
||||
const {profile} = client
|
||||
|
||||
const opt = {
|
||||
results: null,
|
||||
via: null,
|
||||
stopovers: false,
|
||||
transfers: -1,
|
||||
transferTime: 0,
|
||||
accessibility: 'none',
|
||||
bike: false,
|
||||
walkingSpeed: 'normal',
|
||||
startWithWalking: true,
|
||||
tickets: false,
|
||||
polylines: false,
|
||||
subStops: true,
|
||||
entrances: true,
|
||||
remarks: true,
|
||||
scheduledDays: false,
|
||||
departure: '2023-09-12T08:09:10+02:00',
|
||||
products: {},
|
||||
|
||||
firstClass: false,
|
||||
loyaltyCard: {
|
||||
type: loyaltyCards.BAHNCARD,
|
||||
discount: 25,
|
||||
},
|
||||
}
|
||||
|
||||
const berlinWienQuery0 = Object.freeze({
|
||||
getPasslist: false,
|
||||
maxChg: -1,
|
||||
minChgTime: 0,
|
||||
depLocL: [{
|
||||
type: 'S',
|
||||
lid: 'A=1@L=8098160@',
|
||||
}],
|
||||
viaLocL: [],
|
||||
arrLocL: [{
|
||||
type: 'S',
|
||||
lid: 'A=1@L=8000284@',
|
||||
}],
|
||||
jnyFltrL: [
|
||||
{type: 'PROD', mode: 'INC', value: '1023'},
|
||||
{type: 'META', mode: 'INC', meta: 'notBarrierfree'},
|
||||
],
|
||||
gisFltrL: [],
|
||||
getTariff: false,
|
||||
ushrp: true,
|
||||
getPT: true,
|
||||
getIV: false,
|
||||
getPolyline: false,
|
||||
outDate: '20230912',
|
||||
outTime: '080910',
|
||||
outFrwd: true,
|
||||
})
|
||||
|
||||
tap.test('formats a journeys() request correctly (DB)', (t) => {
|
||||
const ctx = {profile, opt}
|
||||
|
||||
// transformJourneysQuery() mutates its 2nd argument!
|
||||
const query = {...berlinWienQuery0}
|
||||
const req = profile.transformJourneysQuery(ctx, query)
|
||||
|
||||
t.same(req, {
|
||||
...berlinWienQuery0,
|
||||
trfReq: {
|
||||
jnyCl: 2,
|
||||
tvlrProf: [{
|
||||
type: 'E', // "adult"
|
||||
redtnCard: 2, // BahnCard 25
|
||||
}],
|
||||
cType: 'PK',
|
||||
},
|
||||
})
|
||||
t.end()
|
||||
})
|
Loading…
Add table
Reference in a new issue