db-vendo-client/test/e2e/rsag.js

129 lines
2.8 KiB
JavaScript
Raw Normal View History

import tap from 'tap';
2020-03-10 23:48:01 +01:00
import {createWhen} from './lib/util.js';
import {createClient} from '../../index.js';
import {profile as rsagProfile} from '../../p/rsag/index.js';
import {createValidateFptfWith as createValidate} from './lib/validate-fptf-with.js';
import {testJourneysStationToStation} from './lib/journeys-station-to-station.js';
import {testEarlierLaterJourneys} from './lib/earlier-later-journeys.js';
import {testRefreshJourney} from './lib/refresh-journey.js';
import {testArrivals} from './lib/arrivals.js';
import {testReachableFrom} from './lib/reachable-from.js';
2020-03-10 23:48:01 +01:00
const T_MOCK = 1671260400 * 1000; // 2022-12-17T08:00:00+01:00
const when = createWhen(rsagProfile.timezone, rsagProfile.locale, T_MOCK);
2020-03-10 23:48:01 +01:00
const cfg = {
when,
// stationCoordsOptional: false,
2022-05-07 16:17:37 +02:00
products: rsagProfile.products,
2020-03-10 23:48:01 +01:00
minLatitude: 52.299,
maxLatitude: 54.862,
minLongitude: 9.121,
maxLongitude: 14.824,
};
2020-03-10 23:48:01 +01:00
const validate = createValidate(cfg);
2020-03-10 23:48:01 +01:00
const client = createClient(rsagProfile, 'public-transport/hafas-client:test');
2020-03-10 23:48:01 +01:00
const sternwarte = '704956';
const sternwarte2 = '708539';
const weißesKreuz = '708573';
2020-03-10 23:48:01 +01:00
2021-05-20 16:42:43 +01:00
tap.test('journeys  Platz der Jugend to Weißes Kreuz', async (t) => {
2020-03-10 23:48:01 +01:00
const res = await client.journeys(sternwarte, weißesKreuz, {
results: 4,
departure: when,
stopovers: true,
});
2020-03-10 23:48:01 +01:00
await testJourneysStationToStation({
test: t,
res,
validate,
fromIds: [sternwarte, sternwarte2],
toId: weißesKreuz,
});
t.end();
});
2020-03-10 23:48:01 +01:00
// todo: journeys, walkingSpeed
// todo: via works with detour
2021-05-20 16:42:43 +01:00
tap.test('earlier/later journeys', async (t) => {
2020-03-10 23:48:01 +01:00
await testEarlierLaterJourneys({
test: t,
fetchJourneys: client.journeys,
validate,
fromId: sternwarte,
toId: weißesKreuz,
when,
});
2020-03-10 23:48:01 +01:00
t.end();
});
2020-03-10 23:48:01 +01:00
2021-05-20 16:42:43 +01:00
tap.test('refreshJourney', async (t) => {
2020-03-10 23:48:01 +01:00
await testRefreshJourney({
test: t,
fetchJourneys: client.journeys,
refreshJourney: client.refreshJourney,
validate,
fromId: sternwarte,
toId: weißesKreuz,
when,
});
t.end();
});
2020-03-10 23:48:01 +01:00
2021-05-20 16:42:43 +01:00
tap.test('arrivals at Platz der Jugend', async (t) => {
const res = await client.arrivals(sternwarte, {
duration: 30, when,
});
2020-03-10 23:48:01 +01:00
await testArrivals({
test: t,
res,
validate,
ids: [
sternwarte,
'708539', // Rostock Sternwarte
],
});
t.end();
});
2020-03-10 23:48:01 +01:00
// todo: nearby
2021-05-20 16:42:43 +01:00
tap.test('radar', async (t) => {
const res = await client.radar({
2020-03-10 23:48:01 +01:00
north: 54.116968,
west: 12.029738,
south: 54.060517,
east: 12.203261,
2020-03-10 23:48:01 +01:00
}, {
duration: 5 * 60, when, results: 10,
});
2020-03-10 23:48:01 +01:00
validate(t, res, 'radarResult', 'res');
t.end();
});
2020-03-10 23:48:01 +01:00
2021-05-20 16:42:43 +01:00
tap.test('reachableFrom', async (t) => {
2020-03-10 23:48:01 +01:00
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,
2020-03-10 23:48:01 +01:00
},
when,
maxDuration: 15,
validate,
});
t.end();
});