parse line.fahrtNr, adapt tests , adapt docs 📝

This commit is contained in:
Jannis R 2018-08-22 19:02:56 +02:00
parent 858fc209bb
commit 9257d3ad7d
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
6 changed files with 12 additions and 0 deletions

View file

@ -86,6 +86,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: '18299', id: '18299',
fahrtNr: '12345',
mode: 'train', mode: 'train',
product: 'suburban', product: 'suburban',
public: true, public: true,
@ -113,6 +114,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: '16441', id: '16441',
fahrtNr: '54321',
mode: 'train', mode: 'train',
product: 'suburban', product: 'suburban',
public: true, public: true,
@ -137,6 +139,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: '19494', id: '19494',
fahrtNr: '11111',
mode: 'train', mode: 'train',
product: 'subway', product: 'subway',
public: true, public: true,

View file

@ -139,6 +139,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: '16845', id: '16845',
fahrtNr: '12345',
name: 'S7', name: 'S7',
public: true, public: true,
mode: 'train', mode: 'train',

View file

@ -50,6 +50,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: 's9', id: 's9',
fahrtNr: '12345',
name: 'S9', name: 'S9',
public: true, public: true,
mode: 'train', mode: 'train',
@ -122,6 +123,7 @@ The response may look like this:
line: { line: {
type: 'line', type: 'line',
id: 'm2', id: 'm2',
fahrtNr: '54321',
name: 'M2', name: 'M2',
public: true, public: true,
mode: 'train', mode: 'train',

View file

@ -101,6 +101,7 @@ The response looked like this:
line: { line: {
type: 'line', type: 'line',
id: '18299', id: '18299',
fahrtNr: '12345',
name: 'S9', name: 'S9',
public: true, public: true,
mode: 'train', mode: 'train',

View file

@ -15,6 +15,7 @@ const createParseLine = (profile, opt, {operators}) => {
const res = { const res = {
type: 'line', type: 'line',
id: null, id: null,
fahrtNr: p.prodCtx && p.prodCtx.num || null,
name: p.line || p.name, name: p.line || p.name,
public: true public: true
} }

View file

@ -82,6 +82,10 @@ const createValidateLine = (cfg) => {
const validateLine = (val, line, name = 'line') => { const validateLine = (val, line, name = 'line') => {
defaultValidators.line(val, line, name) defaultValidators.line(val, line, name)
a.strictEqual(typeof line.fahrtNr, 'string', name + ' must be string')
a.ok(line.fahrtNr, name + ' must not be empty')
a.ok(validLineModes.includes(line.mode), name + '.mode is invalid') a.ok(validLineModes.includes(line.mode), name + '.mode is invalid')
} }
return validateLine return validateLine