mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parseWarning: fix parseMsgEvent 🐛
This commit is contained in:
parent
616da57550
commit
e049aa3d04
4 changed files with 3779 additions and 1 deletions
|
@ -19,7 +19,8 @@ const parseMsgEdge = (ctx) => (e) => {
|
|||
res.toLoc = e.toLocation || null
|
||||
return res
|
||||
}
|
||||
const parseMsgEvent = ({profile}) => (e) => {
|
||||
const parseMsgEvent = (ctx) => (e) => {
|
||||
const {profile} = ctx // todo: test that covers this
|
||||
return {
|
||||
// todo: rename `Loc` -> `Location` [breaking]
|
||||
fromLoc: e.fromLocation || null,
|
||||
|
|
102
test/db-netz-remarks.js
Normal file
102
test/db-netz-remarks.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
'use strict'
|
||||
|
||||
const test = require('tape')
|
||||
|
||||
const parseCommon = require('../parse/common')
|
||||
const defaultProfile = require('../lib/default-profile')
|
||||
const res = require('./fixtures/db-netz-remarks.json')
|
||||
|
||||
const profile = {
|
||||
...defaultProfile,
|
||||
locale: 'de-DE',
|
||||
timezone: 'Europe/Berlin',
|
||||
products: [
|
||||
{id: 'a', bitmasks: [1, 2, 4, 8], name: 'A'},
|
||||
{id: 'b', bitmasks: [16, 32, 64, 128], name: 'B'},
|
||||
{id: 'c', bitmasks: [256, 512], name: 'C'}
|
||||
]
|
||||
}
|
||||
|
||||
const opt = {
|
||||
remarks: true
|
||||
}
|
||||
|
||||
test('parseCommon parses a DB Netz response properly', (t) => {
|
||||
const {warnings} = profile.parseCommon({profile, opt, res})
|
||||
t.pass('parsed without throwing')
|
||||
const warning = warnings.find(w => w.id === 'HIM_FREETEXT_447862')
|
||||
|
||||
t.deepEqual(warning, {
|
||||
id: 'HIM_FREETEXT_447862',
|
||||
type: 'warning',
|
||||
summary: 'Abweichung Fpl f Zmst BKRW - NEB nur nach Gl101',
|
||||
text: 'Brückenarbeiten NKK// BKAR S-Bahn BrüArb Pankgrafenstraße - BKAR nur Gl101 für die NEB nutzbar / 59047 Po 2.2 in Bln-Karow S-B Bft',
|
||||
icon: { type: 'HIM11307', title: null },
|
||||
priority: 80,
|
||||
category: 1,
|
||||
products: { a: true, b: true, c: true },
|
||||
edges: [{
|
||||
dir: 3,
|
||||
icoCrd: { x: 13469131, y: 52614672, type: 'WGS84' },
|
||||
msgRefL: [ 3, 7, 17, 18, 20, 21 ],
|
||||
icon: { type: 'HIM11216', title: null },
|
||||
fromLoc: {
|
||||
type: 'stop',
|
||||
id: '8011046',
|
||||
name: 'Berlin-Karow (BKAR)',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '8011046',
|
||||
latitude: 52.614672,
|
||||
longitude: 13.469131
|
||||
},
|
||||
products: { a: true, b: false, c: true }
|
||||
},
|
||||
toLoc: {
|
||||
type: 'stop',
|
||||
id: '8011046',
|
||||
name: 'Berlin-Karow (BKAR)',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '8011046',
|
||||
latitude: 52.614672,
|
||||
longitude: 13.469131
|
||||
},
|
||||
products: { a: true, b: false, c: true }
|
||||
}
|
||||
}],
|
||||
events: [{
|
||||
fromLoc: {
|
||||
type: 'stop',
|
||||
id: '8011046',
|
||||
name: 'Berlin-Karow (BKAR)',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '8011046',
|
||||
latitude: 52.614672,
|
||||
longitude: 13.469131
|
||||
},
|
||||
products: { a: true, b: false, c: true }
|
||||
},
|
||||
toLoc: {
|
||||
type: 'stop',
|
||||
id: '8011046',
|
||||
name: 'Berlin-Karow (BKAR)',
|
||||
location: {
|
||||
type: 'location',
|
||||
id: '8011046',
|
||||
latitude: 52.614672,
|
||||
longitude: 13.469131
|
||||
},
|
||||
products: { a: true, b: false, c: true }
|
||||
},
|
||||
start: '2020-01-11T00:00:00+01:00',
|
||||
end: '2020-04-03T23:59:00+02:00',
|
||||
sections: [ '6500' ]
|
||||
}],
|
||||
validFrom: '2019-12-15T00:00:00+01:00',
|
||||
validUntil: '2020-05-29T04:00:00+02:00',
|
||||
modified: '2019-10-26T04:09:19+02:00'
|
||||
})
|
||||
t.end()
|
||||
})
|
3674
test/fixtures/db-netz-remarks.json
vendored
Normal file
3674
test/fixtures/db-netz-remarks.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,7 @@ require('./format')
|
|||
require('./bvg-journey')
|
||||
require('./vbb-departures')
|
||||
require('./bvg-radar')
|
||||
require('./db-netz-remarks')
|
||||
|
||||
require('./throttle')
|
||||
require('./retry')
|
||||
|
|
Loading…
Add table
Reference in a new issue