add RSAG E2E tests

This commit is contained in:
Jannis R 2020-03-10 23:48:01 +01:00 committed by Jannis Redmann
parent 84637b2e96
commit 522248b908
2 changed files with 128 additions and 0 deletions

View file

@ -16,6 +16,7 @@ require('./hvv')
require('./vsn') require('./vsn')
require('./vbn') require('./vbn')
require('./rmv') require('./rmv')
require('./rsag')
require('./db-busradar-nrw') require('./db-busradar-nrw')
require('./invg') require('./invg')
require('./pkp') require('./pkp')

127
test/e2e/rsag.js Normal file
View file

@ -0,0 +1,127 @@
'use strict'
const assert = require('assert')
const tapePromise = require('tape-promise').default
const tape = require('tape')
const {createWhen} = require('./lib/util')
const createClient = require('../..')
const rsagProfile = require('../../p/rsag')
const products = require('../../p/rsag/products')
const createValidate = require('./lib/validate-fptf-with')
const testJourneysStationToStation = require('./lib/journeys-station-to-station')
const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
const testRefreshJourney = require('./lib/refresh-journey')
const testArrivals = require('./lib/arrivals')
const testReachableFrom = require('./lib/reachable-from')
const when = createWhen(rsagProfile.timezone, rsagProfile.locale)
const cfg = {
when,
// stationCoordsOptional: false,
products,
minLatitude: 52.299,
maxLatitude: 54.862,
minLongitude: 9.121,
maxLongitude: 14.824,
}
const validate = createValidate(cfg)
const test = tapePromise(tape)
const client = createClient(rsagProfile, 'public-transport/hafas-client:test')
const sternwarte = '704956'
const sternwarte2 = '708539'
const weißesKreuz = '708573'
test('journeys  Platz der Jugend to Weißes Kreuz', async (t) => {
const res = await client.journeys(sternwarte, weißesKreuz, {
results: 4,
departure: when,
stopovers: true
})
await testJourneysStationToStation({
test: t,
res,
validate,
fromId: sternwarte,
toId: weißesKreuz
})
t.end()
})
// todo: journeys, walkingSpeed
// todo: via works with detour
test('earlier/later journeys', async (t) => {
await testEarlierLaterJourneys({
test: t,
fetchJourneys: client.journeys,
validate,
fromId: sternwarte,
toId: weißesKreuz,
when
})
t.end()
})
test.skip('refreshJourney', async (t) => {
await testRefreshJourney({
test: t,
fetchJourneys: client.journeys,
refreshJourney: client.refreshJourney,
validate,
fromId: sternwarte,
toId: weißesKreuz,
when
})
t.end()
})
test('arrivals at Platz der Jugend', async (t) => {
const arrivals = await client.arrivals(sternwarte, {
duration: 30, when
})
validate(t, arrivals, 'arrivals', 'arrivals')
t.ok(arrivals.length > 0, 'must be >0 arrivals')
t.deepEqual(arrivals, arrivals.sort((a, b) => t.when > b.when))
t.end()
})
// todo: nearby
test.skip('radar', async (t) => {
const vehicles = await client.radar({
north: 54.116968,
west: 12.029738,
south: 54.060517,
east: 12.203261
}, {
duration: 5 * 60, when, results: 10
})
validate(t, vehicles, 'movements', 'vehicles')
t.end()
})
test('reachableFrom', async (t) => {
await testReachableFrom({
test: t,
reachableFrom: client.reachableFrom,
address: {
type: 'location',
id: '990004158',
address: 'Rostock - Stadtmitte, Pläterstraße 2',
latitude: 54.091285, longitude: 12.13648
},
when,
maxDuration: 15,
validate
})
t.end()
})