From 024aa0e94825bf98d1be3f408ba2621c349a3e62 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 12 Dec 2017 23:15:06 +0100 Subject: [PATCH] deal with some todos, add more --- format/address.js | 5 +++-- format/poi.js | 5 +++-- p/db/index.js | 2 +- parse/journey.js | 1 - test/db.js | 2 +- test/util.js | 6 ++++-- test/vbb.js | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/format/address.js b/format/address.js index b629ecc6..01f90b11 100644 --- a/format/address.js +++ b/format/address.js @@ -3,8 +3,9 @@ const formatCoord = require('./coord') const formatAddress = (a) => { - // todo: type-checking, better error msgs - if (!a.latitude || !a.longitude || !a.name) throw new Error('invalid address.') + if (!a.type !== 'location' || !a.latitude || !a.longitude || !a.address) { + throw new Error('invalid address') + } return { type: 'A', diff --git a/format/poi.js b/format/poi.js index cef0c55a..bb2d137d 100644 --- a/format/poi.js +++ b/format/poi.js @@ -3,8 +3,9 @@ const formatCoord = require('./coord') const formatPoi = (p) => { - // todo: type-checking, better error msgs - if (!p.latitude || !p.longitude || !p.id || !p.name) throw new Error('invalid poi.') + if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) { + throw new Error('invalid POI') + } return { type: 'P', diff --git a/p/db/index.js b/p/db/index.js index d42a7b97..676dbdcc 100644 --- a/p/db/index.js +++ b/p/db/index.js @@ -42,7 +42,7 @@ const transformJourneysQuery = (query, opt) => { if (opt.bike) filters.push(bike) query.trfReq = { - jnyCl: 2, // todo + jnyCl: opt.firstClass === true ? 1 : 2, tvlrProf: [{ type: 'E', redtnCard: opt.loyaltyCard diff --git a/parse/journey.js b/parse/journey.js index 7e66d5d3..7dc9c737 100644 --- a/parse/journey.js +++ b/parse/journey.js @@ -11,7 +11,6 @@ const createParseJourney = (profile, stations, lines, remarks) => { // todo: c.dep.dProgType, c.arr.dProgType // todo: c.conSubscr // todo: c.trfRes x vbb-parse-ticket - // todo: use computed information from part const parseJourney = (j) => { const parts = j.secL.map(part => parsePart(j, part)) const res = { diff --git a/test/db.js b/test/db.js index 340373f2..9c76627a 100644 --- a/test/db.js +++ b/test/db.js @@ -16,7 +16,7 @@ const { assertValidLocation, assertValidLine, assertValidStopover, - when, isValidWhen // todo: timezone + when, isValidWhen } = require('./util.js') const assertValidStationProducts = (t, p) => { diff --git a/test/util.js b/test/util.js index ced875da..10c8dc52 100644 --- a/test/util.js +++ b/test/util.js @@ -89,8 +89,10 @@ const hour = 60 * 60 * 1000 const week = 7 * 24 * hour // next Monday 10 am -const dt = DateTime.local().startOf('week').plus({weeks: 1, hours: 10}) -const when = new Date(dt.toISO()) +const when = DateTime.fromMillis(Date.now(), { + zone: 'Europe/Berlin', + locale: 'de-DE' +}).startOf('week').plus({weeks: 1, hours: 10}).toJSDate() const isValidWhen = (w) => { const ts = +new Date(w) if (Number.isNaN(ts)) return false diff --git a/test/vbb.js b/test/vbb.js index 04682321..62d18222 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -19,7 +19,7 @@ const { assertValidLine: _assertValidLine, assertValidStopover, hour, when, - assertValidWhen, // todo: timezone + assertValidWhen, assertValidTicket } = require('./util')