diff --git a/test/bvg.js b/test/bvg.js index af745a4c..c359f8fb 100644 --- a/test/bvg.js +++ b/test/bvg.js @@ -8,6 +8,8 @@ const shorten = require('vbb-short-station-name') const tapePromise = require('tape-promise').default const tape = require('tape') const isRoughlyEqual = require('is-roughly-equal') +const {DateTime} = require('luxon') +const flatMap = require('lodash/flatMap') const createClient = require('..') const bvgProfile = require('../p/bvg') @@ -131,6 +133,40 @@ test('journeys – fails with no product', (t) => { t.end() }) +test('journeys – BerlKönig', async (t) => { + const when = DateTime.fromMillis(Date.now(), { + zone: 'Europe/Berlin', + locale: 'de-De', + }).startOf('day').plus({days: 1, hours: 18}).toISO() + + const {journeys} = await client.journeys({ + type: 'location', + address: '12101 Berlin-Tempelhof, Peter-Str.r-Weg 1', + latitude: 52.476283, + longitude: 13.384947 + }, { + type: 'location', + id: '900981505', + poi: true, + name: 'Berlin, Tempelhofer Park Eingang Oderstr.', + latitude: 52.476688, + longitude: 13.41872 + }, { + berlkoenig: true, + departure: when + }) + + const withBerlkoenig = flatMap(journeys, j => j.legs) + .find(l => l.line && l.line.product === 'berlkoenig') + t.ok(withBerlkoenig, 'journey with BerlKönig not found') + + t.ok(withBerlkoenig.line) + t.equal(withBerlkoenig.line.public, true) + t.equal(withBerlkoenig.line.mode, 'taxi') + t.equal(withBerlkoenig.line.product, 'berlkoenig') + t.end() +}) + test('earlier/later journeys', async (t) => { await testEarlierLaterJourneys({ test: t,