mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
add test: VSN with platform objects ✅
test for 5cddd40
This commit is contained in:
parent
2612494970
commit
da01544b42
4 changed files with 703 additions and 0 deletions
75
test/fixtures/vsn-departures.js
vendored
Normal file
75
test/fixtures/vsn-departures.js
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
tripId: '1|265947|0|80|1082020',
|
||||
stop: {
|
||||
type: 'stop',
|
||||
id: '8000050',
|
||||
name: 'Bremen Hbf',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '8000050',
|
||||
latitude: 53.083478,
|
||||
longitude: 8.813833,
|
||||
},
|
||||
products: {
|
||||
nationalExpress: true,
|
||||
national: true,
|
||||
regionalExpress: true,
|
||||
regional: true,
|
||||
suburban: true,
|
||||
bus: true,
|
||||
ferry: false,
|
||||
subway: false,
|
||||
tram: false,
|
||||
anrufSammelTaxi: false,
|
||||
},
|
||||
station: {
|
||||
type: 'station',
|
||||
id: '9013927',
|
||||
name: 'Bremen Hbf',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '9013927',
|
||||
latitude: 53.083478,
|
||||
longitude: 8.813833
|
||||
},
|
||||
products: {
|
||||
nationalExpress: true,
|
||||
national: true,
|
||||
regionalExpress: true,
|
||||
regional: true,
|
||||
suburban: true,
|
||||
bus: true,
|
||||
ferry: false,
|
||||
subway: false,
|
||||
tram: true,
|
||||
anrufSammelTaxi: true,
|
||||
},
|
||||
isMeta: true,
|
||||
}
|
||||
},
|
||||
when: '2020-08-01T18:42:00+02:00',
|
||||
plannedWhen: '2020-08-01T17:44:00+02:00',
|
||||
delay: 3480,
|
||||
platform: '8',
|
||||
plannedPlatform: '8',
|
||||
direction: 'Frankfurt(Main) Hbf',
|
||||
provenance: null,
|
||||
line: {
|
||||
type: 'line',
|
||||
id: '80-30',
|
||||
fahrtNr: '2315',
|
||||
name: 'IC 2315',
|
||||
public: true,
|
||||
adminCode: '80____',
|
||||
mode: 'train',
|
||||
product: 'national',
|
||||
operator: {
|
||||
type: 'operator',
|
||||
id: 'db-fernverkehr',
|
||||
name: 'DB Fernverkehr',
|
||||
},
|
||||
},
|
||||
remarks: [],
|
||||
}
|
589
test/fixtures/vsn-departures.json
vendored
Normal file
589
test/fixtures/vsn-departures.json
vendored
Normal file
|
@ -0,0 +1,589 @@
|
|||
{
|
||||
"common": {
|
||||
"locL": [
|
||||
{
|
||||
"lid": "A=1@O=Bremen Hbf@X=8813833@Y=53083478@U=80@L=8000050@",
|
||||
"type": "S",
|
||||
"name": "Bremen Hbf",
|
||||
"icoX": 2,
|
||||
"extId": "8000050",
|
||||
"state": "F",
|
||||
"crd": {
|
||||
"x": 8813833,
|
||||
"y": 53083478,
|
||||
"layerX": 0,
|
||||
"crdSysX": 0
|
||||
},
|
||||
"pCls": 63,
|
||||
"pRefL": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16
|
||||
],
|
||||
"entry": true,
|
||||
"mMastLocX": 1
|
||||
},
|
||||
{
|
||||
"lid": "A=1@O=Bremen Hbf@X=8813833@Y=53083478@U=80@L=9013927@",
|
||||
"type": "S",
|
||||
"name": "Bremen Hbf",
|
||||
"icoX": 2,
|
||||
"extId": "9013927",
|
||||
"state": "F",
|
||||
"crd": {
|
||||
"x": 8813833,
|
||||
"y": 53083478,
|
||||
"layerX": 0,
|
||||
"crdSysX": 0
|
||||
},
|
||||
"meta": true,
|
||||
"pCls": 831,
|
||||
"isMainMast": true
|
||||
},
|
||||
{
|
||||
"lid": "A=1@O=Frankfurt(Main) Hbf@X=8663785@Y=50107149@U=80@L=8000105@",
|
||||
"type": "S",
|
||||
"name": "Frankfurt(Main) Hbf",
|
||||
"icoX": 2,
|
||||
"extId": "8000105",
|
||||
"state": "F",
|
||||
"crd": {
|
||||
"x": 8663785,
|
||||
"y": 50107149,
|
||||
"layerX": 0,
|
||||
"crdSysX": 0
|
||||
},
|
||||
"pCls": 59
|
||||
}
|
||||
],
|
||||
"prodL": [
|
||||
{
|
||||
"pid": "L::1::IC::B3150904150::IC_3150904150::*",
|
||||
"name": "IC 2315",
|
||||
"nameS": "30",
|
||||
"number": "2315",
|
||||
"icoX": 0,
|
||||
"cls": 2,
|
||||
"oprX": 0,
|
||||
"prodCtx": {
|
||||
"name": "IC 2315 ",
|
||||
"num": "2315",
|
||||
"line": "30",
|
||||
"lineId": "80_____30",
|
||||
"matchId": "2315",
|
||||
"catOut": "IC ",
|
||||
"catOutS": "IC",
|
||||
"catOutL": "InterCity",
|
||||
"catIn": "IC",
|
||||
"catCode": "1",
|
||||
"admin": "80____"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ICE",
|
||||
"icoX": 2,
|
||||
"cls": 1,
|
||||
"prodCtx": {
|
||||
"name": "ICE ",
|
||||
"line": "",
|
||||
"catOut": "ICE ",
|
||||
"catOutS": "ICE",
|
||||
"catOutL": "InterCityExpress"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "NJ",
|
||||
"icoX": 2,
|
||||
"cls": 1,
|
||||
"prodCtx": {
|
||||
"name": "NJ ",
|
||||
"line": "",
|
||||
"catOut": "NJ ",
|
||||
"catOutS": "NJ",
|
||||
"catOutL": "Nightjet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "EC",
|
||||
"icoX": 0,
|
||||
"cls": 2,
|
||||
"prodCtx": {
|
||||
"name": "EC ",
|
||||
"line": "",
|
||||
"catOut": "EC ",
|
||||
"catOutS": "EC",
|
||||
"catOutL": "EuroCity"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "IC",
|
||||
"icoX": 0,
|
||||
"cls": 2,
|
||||
"prodCtx": {
|
||||
"name": "IC ",
|
||||
"line": "",
|
||||
"catOut": "IC ",
|
||||
"catOutS": "IC",
|
||||
"catOutL": "InterCity"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "DPF",
|
||||
"nameS": "DPF",
|
||||
"icoX": 3,
|
||||
"cls": 4,
|
||||
"prodCtx": {
|
||||
"name": "DPF",
|
||||
"line": "DPF",
|
||||
"lineId": "NY_____DPF",
|
||||
"catOut": "DPF ",
|
||||
"catOutS": "DPF",
|
||||
"catOutL": "Fernreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "UEX",
|
||||
"nameS": "UEX",
|
||||
"icoX": 3,
|
||||
"cls": 4,
|
||||
"prodCtx": {
|
||||
"name": "UEX",
|
||||
"line": "UEX",
|
||||
"lineId": "NYUEX__UEX",
|
||||
"catOut": "DPF ",
|
||||
"catOutS": "DPF",
|
||||
"catOutL": "Fernreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "MEX",
|
||||
"nameS": "MEX",
|
||||
"icoX": 4,
|
||||
"cls": 8,
|
||||
"prodCtx": {
|
||||
"name": "MEX",
|
||||
"line": "MEX",
|
||||
"lineId": "E0_____MEX",
|
||||
"catOut": "Zug ",
|
||||
"catOutS": "DPN",
|
||||
"catOutL": "Nahreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RB37",
|
||||
"nameS": "RB37",
|
||||
"icoX": 4,
|
||||
"cls": 8,
|
||||
"prodCtx": {
|
||||
"name": "RB37",
|
||||
"line": "RB37",
|
||||
"lineId": "X1_____RB37",
|
||||
"catOut": "Zug ",
|
||||
"catOutS": "DPN",
|
||||
"catOutL": "Nahreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RB41",
|
||||
"nameS": "RB41",
|
||||
"icoX": 4,
|
||||
"cls": 8,
|
||||
"prodCtx": {
|
||||
"name": "RB41",
|
||||
"line": "RB41",
|
||||
"lineId": "R1_____RB41",
|
||||
"catOut": "Zug ",
|
||||
"catOutS": "DPN",
|
||||
"catOutL": "Nahreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RB58",
|
||||
"nameS": "RB58",
|
||||
"icoX": 4,
|
||||
"cls": 8,
|
||||
"prodCtx": {
|
||||
"name": "RB58",
|
||||
"line": "RB58",
|
||||
"lineId": "N1_____RB58",
|
||||
"catOut": "Zug ",
|
||||
"catOutS": "DPN",
|
||||
"catOutL": "Nahreisezug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RE1",
|
||||
"nameS": "RE1",
|
||||
"icoX": 4,
|
||||
"cls": 8,
|
||||
"prodCtx": {
|
||||
"name": "RE1",
|
||||
"line": "RE1",
|
||||
"lineId": "de:LNVG:RE1:",
|
||||
"catOut": "RE ",
|
||||
"catOutS": "RE",
|
||||
"catOutL": "Regional-Express"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RS1",
|
||||
"nameS": "RS1",
|
||||
"icoX": 5,
|
||||
"cls": 16,
|
||||
"prodCtx": {
|
||||
"name": "RS1",
|
||||
"line": "RS1",
|
||||
"lineId": "de:VBN:RS1:",
|
||||
"catOut": "S ",
|
||||
"catOutS": "DPS",
|
||||
"catOutL": "S-Bahn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RS2",
|
||||
"nameS": "RS2",
|
||||
"icoX": 5,
|
||||
"cls": 16,
|
||||
"prodCtx": {
|
||||
"name": "RS2",
|
||||
"line": "RS2",
|
||||
"lineId": "de:VBN:RS2:",
|
||||
"catOut": "S ",
|
||||
"catOutS": "DPS",
|
||||
"catOutL": "S-Bahn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RS3",
|
||||
"nameS": "RS3",
|
||||
"icoX": 5,
|
||||
"cls": 16,
|
||||
"prodCtx": {
|
||||
"name": "RS3",
|
||||
"line": "RS3",
|
||||
"lineId": "de:VBN:RS3:",
|
||||
"catOut": "S ",
|
||||
"catOutS": "DPS",
|
||||
"catOutL": "S-Bahn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RS4",
|
||||
"nameS": "RS4",
|
||||
"icoX": 5,
|
||||
"cls": 16,
|
||||
"prodCtx": {
|
||||
"name": "RS4",
|
||||
"line": "RS4",
|
||||
"lineId": "de:VBN:RS4:",
|
||||
"catOut": "S ",
|
||||
"catOutS": "DPS",
|
||||
"catOutL": "S-Bahn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SEV",
|
||||
"nameS": "SEV",
|
||||
"icoX": 6,
|
||||
"cls": 32,
|
||||
"prodCtx": {
|
||||
"name": "SEV",
|
||||
"line": "SEV",
|
||||
"lineId": "R1_____SEV",
|
||||
"catOut": "SEV ",
|
||||
"catOutS": "Bsv",
|
||||
"catOutL": "Schienenersatzverkehr"
|
||||
}
|
||||
}
|
||||
],
|
||||
"polyL": [],
|
||||
"layerL": [
|
||||
{
|
||||
"id": "standard",
|
||||
"name": "standard",
|
||||
"index": 0,
|
||||
"annoCnt": 0
|
||||
}
|
||||
],
|
||||
"crdSysL": [
|
||||
{
|
||||
"id": "standard",
|
||||
"index": 0,
|
||||
"type": "WGS84"
|
||||
}
|
||||
],
|
||||
"opL": [
|
||||
{
|
||||
"name": "DB Fernverkehr",
|
||||
"icoX": 1,
|
||||
"id": "1175"
|
||||
}
|
||||
],
|
||||
"remL": [
|
||||
{
|
||||
"type": "A",
|
||||
"code": "FR",
|
||||
"prio": 260,
|
||||
"icoX": 7,
|
||||
"txtN": "Fahrradmitnahme reservierungspflichtig"
|
||||
},
|
||||
{
|
||||
"type": "A",
|
||||
"code": "FK",
|
||||
"prio": 260,
|
||||
"icoX": 8,
|
||||
"txtN": "Fahrradmitnahme begrenzt möglich"
|
||||
}
|
||||
],
|
||||
"himL": [
|
||||
{
|
||||
"hid": "15528",
|
||||
"act": true,
|
||||
"head": "Corona-Präventionsmaßnahme",
|
||||
"text": "Derzeit gilt die Mund-Nasen-Bedeckungspflicht im ÖPNV. Danke, dass Sie sich und andere Fahrgäste schützen und zur Sicherheit des Bus- und Bahnfahrens beitragen!",
|
||||
"icoX": 9,
|
||||
"prio": 1,
|
||||
"prod": 65535,
|
||||
"lModDate": "20200602",
|
||||
"lModTime": "153245",
|
||||
"sDate": "20200424",
|
||||
"sTime": "150000",
|
||||
"eDate": "20201231",
|
||||
"eTime": "235900",
|
||||
"sDaily": "000000",
|
||||
"eDaily": "235900",
|
||||
"comp": "VBN",
|
||||
"catRefL": [
|
||||
0
|
||||
],
|
||||
"pubChL": [
|
||||
{
|
||||
"name": "timetable",
|
||||
"fDate": "20200424",
|
||||
"fTime": "150000",
|
||||
"tDate": "20201231",
|
||||
"tTime": "235900"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"icoL": [
|
||||
{
|
||||
"res": "prod_ic",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 239,
|
||||
"g": 119,
|
||||
"b": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "DB",
|
||||
"txt": "DB Fernverkehr"
|
||||
},
|
||||
{
|
||||
"res": "prod_ice",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 150,
|
||||
"g": 25,
|
||||
"b": 29
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "prod_ir",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 62,
|
||||
"g": 134,
|
||||
"b": 144
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "prod_reg",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 82,
|
||||
"g": 38,
|
||||
"b": 125
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "prod_comm",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 19,
|
||||
"g": 148,
|
||||
"b": 69
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "prod_bus",
|
||||
"fg": {
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255
|
||||
},
|
||||
"bg": {
|
||||
"r": 0,
|
||||
"g": 92,
|
||||
"b": 169
|
||||
}
|
||||
},
|
||||
{
|
||||
"res": "attr_bike_r"
|
||||
},
|
||||
{
|
||||
"res": "attr_bike"
|
||||
},
|
||||
{
|
||||
"res": "HIM2"
|
||||
}
|
||||
],
|
||||
"himMsgCatL": [
|
||||
{
|
||||
"id": 2
|
||||
}
|
||||
],
|
||||
"lDrawStyleL": [
|
||||
{
|
||||
"sIcoX": 0,
|
||||
"type": "SOLID",
|
||||
"bg": {
|
||||
"r": 239,
|
||||
"g": 119,
|
||||
"b": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SOLID",
|
||||
"bg": {
|
||||
"r": 239,
|
||||
"g": 119,
|
||||
"b": 28
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "DEP",
|
||||
"jnyL": [
|
||||
{
|
||||
"jid": "1|265947|0|80|1082020",
|
||||
"date": "20200801",
|
||||
"prodX": 0,
|
||||
"dirTxt": "Frankfurt(Main) Hbf",
|
||||
"dirFlg": "1",
|
||||
"status": "P",
|
||||
"isRchbl": true,
|
||||
"stbStop": {
|
||||
"locX": 0,
|
||||
"idx": 8,
|
||||
"dProdX": 0,
|
||||
"dPltfS": {
|
||||
"type": "PL",
|
||||
"txt": "8"
|
||||
},
|
||||
"dPltfR": {
|
||||
"type": "U",
|
||||
"txt": "8"
|
||||
},
|
||||
"dTimeS": "174400",
|
||||
"dTimeR": "184200",
|
||||
"dProgType": "PROGNOSED",
|
||||
"type": "N"
|
||||
},
|
||||
"msgL": [
|
||||
{
|
||||
"type": "REM",
|
||||
"remX": 0,
|
||||
"sty": "I",
|
||||
"dspl": "U",
|
||||
"fLocX": 0,
|
||||
"tLocX": 2,
|
||||
"tagL": [
|
||||
"RES_JNY_DTL"
|
||||
],
|
||||
"sort": 1141899264,
|
||||
"persist": false
|
||||
},
|
||||
{
|
||||
"type": "REM",
|
||||
"remX": 1,
|
||||
"sty": "I",
|
||||
"dspl": "U",
|
||||
"fLocX": 0,
|
||||
"tLocX": 2,
|
||||
"tagL": [
|
||||
"RES_JNY_DTL"
|
||||
],
|
||||
"sort": 1141899264,
|
||||
"persist": false
|
||||
},
|
||||
{
|
||||
"type": "HIM",
|
||||
"himX": 0,
|
||||
"sty": "M",
|
||||
"fLocX": 0,
|
||||
"tagL": [
|
||||
"RES_GLB_HDR_H3",
|
||||
"SUM_GLB_HDR_H3"
|
||||
],
|
||||
"sort": 807680508
|
||||
}
|
||||
],
|
||||
"subscr": "F",
|
||||
"prodL": [
|
||||
{
|
||||
"prodX": 0,
|
||||
"fLocX": 0,
|
||||
"tLocX": 2,
|
||||
"fIdx": 8,
|
||||
"tIdx": 20
|
||||
}
|
||||
],
|
||||
"sumLDrawStyleX": 0,
|
||||
"resLDrawStyleX": 1
|
||||
}
|
||||
],
|
||||
"fpB": "20191215",
|
||||
"fpE": "20201212",
|
||||
"planrtTS": "1596298820",
|
||||
"sD": "20200801",
|
||||
"sT": "182119",
|
||||
"locRefL": [
|
||||
0
|
||||
]
|
||||
}
|
|
@ -13,6 +13,7 @@ require('./vbb-departures')
|
|||
require('./bvg-radar')
|
||||
require('./oebb-trip')
|
||||
require('./db-netz-remarks')
|
||||
require('./vsn-departures')
|
||||
|
||||
require('./throttle')
|
||||
require('./retry')
|
||||
|
|
38
test/vsn-departures.js
Normal file
38
test/vsn-departures.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict'
|
||||
|
||||
const test = require('tape')
|
||||
|
||||
const createClient = require('..')
|
||||
const rawProfile = require('../p/vsn')
|
||||
const res = require('./fixtures/vsn-departures.json')
|
||||
const expected = require('./fixtures/vsn-departures.js')
|
||||
|
||||
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
|
||||
const {profile} = client
|
||||
|
||||
const opt = {
|
||||
// results: null,
|
||||
// via: null,
|
||||
// stopovers: true,
|
||||
// transfers: -1,
|
||||
// transferTime: 0,
|
||||
// accessibility: 'none',
|
||||
// bike: false,
|
||||
// tickets: true,
|
||||
// polylines: true,
|
||||
// remarks: true,
|
||||
// walkingSpeed: 'normal',
|
||||
// startWithWalking: true,
|
||||
// scheduledDays: false,
|
||||
// departure: '2020-04-10T20:33+02:00',
|
||||
// products: {}
|
||||
}
|
||||
|
||||
test('parses departures correctly (VSN)', (t) => {
|
||||
const common = profile.parseCommon({profile, opt, res})
|
||||
const ctx = {profile, opt, common, res}
|
||||
|
||||
const dep = profile.parseDeparture(ctx, res.jnyL[0])
|
||||
t.deepEqual(dep, expected)
|
||||
t.end()
|
||||
})
|
Loading…
Add table
Reference in a new issue