mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
ZVV: E2E/integration tests ✅
This commit is contained in:
parent
b2b1b75f04
commit
3f4c05d821
2 changed files with 127 additions and 0 deletions
|
@ -22,3 +22,4 @@ require('./invg')
|
|||
require('./pkp')
|
||||
require('./sncb')
|
||||
require('./svv')
|
||||
require('./zvv')
|
||||
|
|
126
test/e2e/zvv.js
Normal file
126
test/e2e/zvv.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
'use strict'
|
||||
|
||||
const isRoughlyEqual = require('is-roughly-equal')
|
||||
|
||||
const {createWhen} = require('./lib/util')
|
||||
const createClient = require('../..')
|
||||
const zvvProfile = require('../../p/zvv')
|
||||
const products = require('../../p/zvv/products')
|
||||
const createValidate = require('./lib/validate-fptf-with')
|
||||
const {test} = require('./lib/util')
|
||||
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
|
||||
const journeysFailsWithNoProduct = require('./lib/journeys-fails-with-no-product')
|
||||
const testJourneysStationToAddress = require('./lib/journeys-station-to-address')
|
||||
const testJourneysStationToPoi = require('./lib/journeys-station-to-poi')
|
||||
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
|
||||
const testDepartures = require('./lib/departures')
|
||||
const testDeparturesInDirection = require('./lib/departures-in-direction')
|
||||
const testArrivals = require('./lib/arrivals')
|
||||
|
||||
const when = createWhen('Europe/Zurich', 'de-CH')
|
||||
|
||||
const validate = createValidate({
|
||||
when,
|
||||
products,
|
||||
maxLatitude: 47.75,
|
||||
minLongitude: 7.38,
|
||||
minLatitude: 46.99,
|
||||
maxLongitude: 9.71,
|
||||
}, {})
|
||||
|
||||
const client = createClient(zvvProfile, 'public-transport/hafas-client:test')
|
||||
|
||||
const bürkliplatz = '8591105'
|
||||
const ethUniversitätsspital = '8591123'
|
||||
|
||||
test('journeys – Bürkliplatz to ETH/Universitätsspital', async (t) => {
|
||||
const res = await client.journeys(bürkliplatz, ethUniversitätsspital, {
|
||||
results: 4,
|
||||
departure: when,
|
||||
stopovers: true
|
||||
})
|
||||
|
||||
await testJourneysStationToStation({
|
||||
test: t,
|
||||
res,
|
||||
validate,
|
||||
fromId: bürkliplatz,
|
||||
toId: ethUniversitätsspital
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('earlier/later journeys', async (t) => {
|
||||
await testEarlierLaterJourneys({
|
||||
test: t,
|
||||
fetchJourneys: client.journeys,
|
||||
validate,
|
||||
fromId: bürkliplatz,
|
||||
toId: ethUniversitätsspital,
|
||||
when
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('trip details', async (t) => {
|
||||
const res = await client.journeys(bürkliplatz, ethUniversitätsspital, {
|
||||
results: 1, departure: when
|
||||
})
|
||||
|
||||
const p = res.journeys[0].legs.find(l => !l.walking)
|
||||
t.ok(p.tripId, 'precondition failed')
|
||||
t.ok(p.line.name, 'precondition failed')
|
||||
const trip = await client.trip(p.tripId, p.line.name, {when})
|
||||
|
||||
validate(t, trip, 'trip', 'trip')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test.skip('departures at ETH/Universitätsspital', async (t) => { // todo
|
||||
const departures = await client.departures(ethUniversitätsspital, {
|
||||
duration: 5, when,
|
||||
})
|
||||
|
||||
await testDepartures({
|
||||
test: t,
|
||||
departures,
|
||||
validate,
|
||||
id: ethUniversitätsspital
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
// todo: departures in direction
|
||||
// todo: nearby
|
||||
|
||||
test('locations named Rennweg', async (t) => {
|
||||
const rennweg = '8591316'
|
||||
const locations = await client.locations('Rennweg', {
|
||||
results: 20,
|
||||
})
|
||||
|
||||
validate(t, locations, 'locations', 'locations')
|
||||
t.ok(locations.length <= 20)
|
||||
|
||||
t.ok(locations.find(s => s.type === 'stop' || s.type === 'station'))
|
||||
t.ok(locations.some((l) => {
|
||||
return l.station && l.station.id === rennweg || l.id === rennweg
|
||||
}))
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('radar', async (t) => {
|
||||
const vehicles = await client.radar({
|
||||
north: 47.387,
|
||||
west: 8.514,
|
||||
south: 47.356,
|
||||
east: 8.568,
|
||||
}, {
|
||||
duration: 5 * 60, when, results: 10,
|
||||
})
|
||||
|
||||
validate(t, vehicles, 'movements', 'vehicles')
|
||||
t.end()
|
||||
})
|
Loading…
Add table
Reference in a new issue