BVG: test for BerlKönig

This commit is contained in:
Jannis R 2018-10-28 17:55:52 +01:00
parent a40006f5ca
commit 1afe4caf41
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -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,