mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parseWarning: {from,to}Loc -> {from,to}Location 💥✅
This commit is contained in:
parent
90308411fc
commit
e0cdd55908
4 changed files with 26 additions and 28 deletions
|
@ -14,17 +14,15 @@ const parseMsgEdge = (ctx) => (e) => {
|
||||||
'tLocX', 'toLocation'
|
'tLocX', 'toLocation'
|
||||||
])
|
])
|
||||||
res.icon = e.icon || null
|
res.icon = e.icon || null
|
||||||
// todo: rename `Loc` -> `Location` [breaking]
|
res.fromLocation = Array.isArray(e.fromLocations) && e.fromLocations[0] || e.fromLocation || null
|
||||||
res.fromLoc = Array.isArray(e.fromLocations) && e.fromLocations[0] || e.fromLocation || null
|
res.toLocation = Array.isArray(e.toLocations) && e.toLocations[0] || e.toLocation || null
|
||||||
res.toLoc = Array.isArray(e.toLocations) && e.toLocations[0] || e.toLocation || null
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
const parseMsgEvent = (ctx) => (e) => {
|
const parseMsgEvent = (ctx) => (e) => {
|
||||||
const {profile} = ctx // todo: test that covers this
|
const {profile} = ctx // todo: test that covers this
|
||||||
return {
|
return {
|
||||||
// todo: rename `Loc` -> `Location` [breaking]
|
fromLocation: Array.isArray(e.fromLocations) && e.fromLocations[0] || e.fromLocation || null,
|
||||||
fromLoc: Array.isArray(e.fromLocations) && e.fromLocations[0] || e.fromLocation || null,
|
toLocation: Array.isArray(e.toLocations) && e.toLocations[0] || e.toLocation || null,
|
||||||
toLoc: Array.isArray(e.toLocations) && e.toLocations[0] || e.toLocation || null,
|
|
||||||
start: profile.parseDateTime(ctx, e.fDate, e.fTime, null),
|
start: profile.parseDateTime(ctx, e.fDate, e.fTime, null),
|
||||||
end: profile.parseDateTime(ctx, e.tDate, e.tTime, null),
|
end: profile.parseDateTime(ctx, e.tDate, e.tTime, null),
|
||||||
sections: e.sectionNums || [] // todo: parse
|
sections: e.sectionNums || [] // todo: parse
|
||||||
|
|
|
@ -40,7 +40,7 @@ tap.test('parseCommon parses a DB Netz response properly', (t) => {
|
||||||
icoCrd: { x: 13469131, y: 52614672, type: 'WGS84' },
|
icoCrd: { x: 13469131, y: 52614672, type: 'WGS84' },
|
||||||
msgRefL: [ 3, 7, 17, 18, 20, 21 ],
|
msgRefL: [ 3, 7, 17, 18, 20, 21 ],
|
||||||
icon: { type: 'HIM11216', title: null },
|
icon: { type: 'HIM11216', title: null },
|
||||||
fromLoc: {
|
fromLocation: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '8011046',
|
id: '8011046',
|
||||||
name: 'Berlin-Karow (BKAR)',
|
name: 'Berlin-Karow (BKAR)',
|
||||||
|
@ -52,7 +52,7 @@ tap.test('parseCommon parses a DB Netz response properly', (t) => {
|
||||||
},
|
},
|
||||||
products: { a: true, b: false, c: true }
|
products: { a: true, b: false, c: true }
|
||||||
},
|
},
|
||||||
toLoc: {
|
toLocation: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '8011046',
|
id: '8011046',
|
||||||
name: 'Berlin-Karow (BKAR)',
|
name: 'Berlin-Karow (BKAR)',
|
||||||
|
@ -66,7 +66,7 @@ tap.test('parseCommon parses a DB Netz response properly', (t) => {
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
events: [{
|
events: [{
|
||||||
fromLoc: {
|
fromLocation: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '8011046',
|
id: '8011046',
|
||||||
name: 'Berlin-Karow (BKAR)',
|
name: 'Berlin-Karow (BKAR)',
|
||||||
|
@ -78,7 +78,7 @@ tap.test('parseCommon parses a DB Netz response properly', (t) => {
|
||||||
},
|
},
|
||||||
products: { a: true, b: false, c: true }
|
products: { a: true, b: false, c: true }
|
||||||
},
|
},
|
||||||
toLoc: {
|
toLocation: {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
id: '8011046',
|
id: '8011046',
|
||||||
name: 'Berlin-Karow (BKAR)',
|
name: 'Berlin-Karow (BKAR)',
|
||||||
|
|
4
test/fixtures/oebb-trip.js
vendored
4
test/fixtures/oebb-trip.js
vendored
|
@ -88,8 +88,8 @@ const corona = {
|
||||||
edges: [{
|
edges: [{
|
||||||
icoCrd: {x: 14768356, y: 48156724, type: 'WGS84'},
|
icoCrd: {x: 14768356, y: 48156724, type: 'WGS84'},
|
||||||
icon: null,
|
icon: null,
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null
|
toLocation: null
|
||||||
}],
|
}],
|
||||||
validFrom: '2020-05-15T00:00:00+02:00',
|
validFrom: '2020-05-15T00:00:00+02:00',
|
||||||
validUntil: '2020-06-30T23:59:00+02:00',
|
validUntil: '2020-06-30T23:59:00+02:00',
|
||||||
|
|
32
test/fixtures/vsn-remarks.js
vendored
32
test/fixtures/vsn-remarks.js
vendored
|
@ -26,14 +26,14 @@ module.exports = [
|
||||||
{
|
{
|
||||||
icoCrd: { x: 7875575, y: 52201492 },
|
icoCrd: { x: 7875575, y: 52201492 },
|
||||||
icon: null,
|
icon: null,
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null
|
toLocation: null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
events: [
|
events: [
|
||||||
{
|
{
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null,
|
toLocation: null,
|
||||||
start: '2020-02-03T11:11:00+01:00',
|
start: '2020-02-03T11:11:00+01:00',
|
||||||
end: '2020-12-13T00:00:00+01:00',
|
end: '2020-12-13T00:00:00+01:00',
|
||||||
sections: []
|
sections: []
|
||||||
|
@ -79,14 +79,14 @@ module.exports = [
|
||||||
{
|
{
|
||||||
icoCrd: { x: 9395422, y: 51748714 },
|
icoCrd: { x: 9395422, y: 51748714 },
|
||||||
icon: null,
|
icon: null,
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null
|
toLocation: null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
events: [
|
events: [
|
||||||
{
|
{
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null,
|
toLocation: null,
|
||||||
start: '2019-12-15T00:00:00+01:00',
|
start: '2019-12-15T00:00:00+01:00',
|
||||||
end: '2020-12-12T23:59:00+01:00',
|
end: '2020-12-12T23:59:00+01:00',
|
||||||
sections: []
|
sections: []
|
||||||
|
@ -139,14 +139,14 @@ module.exports = [
|
||||||
{
|
{
|
||||||
icoCrd: { x: 9435051, y: 51783147 },
|
icoCrd: { x: 9435051, y: 51783147 },
|
||||||
icon: null,
|
icon: null,
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null
|
toLocation: null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
events: [
|
events: [
|
||||||
{
|
{
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null,
|
toLocation: null,
|
||||||
start: '2019-12-15T00:00:00+01:00',
|
start: '2019-12-15T00:00:00+01:00',
|
||||||
end: '2020-12-12T23:59:00+01:00',
|
end: '2020-12-12T23:59:00+01:00',
|
||||||
sections: []
|
sections: []
|
||||||
|
@ -213,8 +213,8 @@ module.exports = [
|
||||||
categories: [ 0 ],
|
categories: [ 0 ],
|
||||||
events: [
|
events: [
|
||||||
{
|
{
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null,
|
toLocation: null,
|
||||||
start: '2020-02-21T11:31:00+01:00',
|
start: '2020-02-21T11:31:00+01:00',
|
||||||
end: '2020-06-30T23:59:00+02:00',
|
end: '2020-06-30T23:59:00+02:00',
|
||||||
sections: []
|
sections: []
|
||||||
|
@ -288,8 +288,8 @@ module.exports = [
|
||||||
categories: [ 0 ],
|
categories: [ 0 ],
|
||||||
events: [
|
events: [
|
||||||
{
|
{
|
||||||
fromLoc: null,
|
fromLocation: null,
|
||||||
toLoc: null,
|
toLocation: null,
|
||||||
start: '2020-02-21T11:01:00+01:00',
|
start: '2020-02-21T11:01:00+01:00',
|
||||||
end: '2020-06-30T23:59:00+02:00',
|
end: '2020-06-30T23:59:00+02:00',
|
||||||
sections: []
|
sections: []
|
||||||
|
|
Loading…
Add table
Reference in a new issue