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

36 lines
1.1 KiB
JavaScript
Raw Normal View History

import tap from 'tap';
2021-08-05 19:56:05 +02:00
import {createWhen} from './lib/util.js';
import {createClient} from '../../index.js';
import {profile as vorProfile} from '../../p/vor/index.js';
import {createValidateFptfWith as createValidate} from './lib/validate-fptf-with.js';
2021-08-05 19:56:05 +02:00
const T_MOCK = 1671260400 * 1000; // 2022-12-17T08:00:00+01:00
const when = createWhen(vorProfile.timezone, vorProfile.locale, T_MOCK);
2021-08-05 19:56:05 +02:00
const cfg = {
when,
stationCoordsOptional: false,
products: vorProfile.products,
maxLatitude: 47.9504,
maxLongitude: 17.0892,
minLatitude: 45.7206,
minLongitude: 7.8635,
};
const validate = createValidate(cfg);
2021-08-05 19:56:05 +02:00
const client = createClient(vorProfile, 'public-transport/hafas-client:test');
2021-08-05 19:56:05 +02:00
const stPöltenLinzerTor = '431277900';
2021-08-05 19:56:05 +02:00
tap.test('locations named "linzer tor"', async (t) => {
const locations = await client.locations('linzer tor');
2021-08-05 19:56:05 +02:00
validate(t, locations, 'locations', 'locations');
2021-08-05 19:56:05 +02:00
t.ok(locations.some((l) => {
return l.station && l.station.id === stPöltenLinzerTor || l.id === stPöltenLinzerTor;
}), 'St. Pölten Linzer Tor not found');
2021-08-05 19:56:05 +02:00
t.end();
});