diff --git a/p/vbb/index.js b/p/vbb/index.js index 4e0ddd72..3b750d81 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -2,6 +2,7 @@ const shorten = require('vbb-short-station-name') const {to12Digit, to9Digit} = require('vbb-translate-ids') +const parseLineName = require('vbb-parse-line') const _formatStation = require('../../format/station') const _parseLine = require('../../parse/line') @@ -34,6 +35,13 @@ const parseLine = (profile, l) => { } } + const details = parseLineName(l.name) + res.symbol = details.symbol + res.nr = details.nr + res.metro = details.metro + res.express = details.express + res.night = details.night + return res } diff --git a/parse/line.js b/parse/line.js index 01e7954d..af999382 100644 --- a/parse/line.js +++ b/parse/line.js @@ -12,10 +12,7 @@ const parseLine = (profile, p) => { } if (p.cls) res.class = p.cls - if (p.prodCtx) { - res.productCode = +p.prodCtx.catCode - res.productName = p.prodCtx.catOutS - } + if (p.prodCtx) res.productCode = +p.prodCtx.catCode // todo: parse mode, remove from profiles diff --git a/test/vbb.js b/test/vbb.js index 7e039dde..9a367c7d 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -15,7 +15,7 @@ const { assertValidPoi, assertValidAddress, assertValidLocation, - assertValidLine, + assertValidLine: _assertValidLine, assertValidStopover, hour, when, assertValidWhen @@ -32,6 +32,15 @@ const assertValidStationProducts = (t, p) => { t.equal(typeof p.regional, 'boolean') } +const assertValidLine = (t, l) => { + _assertValidLine(t, l) + if (l.symbol !== null) t.equal(typeof l.symbol, 'string') + if (l.nr !== null) t.equal(typeof l.nr, 'number') + if (l.metro !== null) t.equal(typeof l.metro, 'boolean') + if (l.express !== null) t.equal(typeof l.express, 'boolean') + if (l.night !== null) t.equal(typeof l.night, 'boolean') +} + // todo const findStation = (query) => stations(query, true, false)