2024-02-06 22:58:49 +01:00
|
|
|
import tap from 'tap';
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
import {createWhen} from './lib/util.js';
|
|
|
|
import {createClient} from '../../index.js';
|
|
|
|
import {profile as dartProfile} from '../../p/dart/index.js';
|
|
|
|
import {createValidateFptfWith as createValidate} from './lib/validate-fptf-with.js';
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const T_MOCK = 1671260400 * 1000; // 2022-12-17T08:00:00+01:00
|
|
|
|
const when = createWhen(dartProfile.timezone, dartProfile.locale, T_MOCK);
|
2022-04-23 14:40:51 +02:00
|
|
|
|
2021-08-24 18:58:24 +02:00
|
|
|
const cfg = {
|
|
|
|
when,
|
|
|
|
stationCoordsOptional: false,
|
|
|
|
products: dartProfile.products,
|
|
|
|
maxLatitude: 45.391,
|
|
|
|
maxLongitude: -88.176,
|
|
|
|
minLatitude: 37.745,
|
|
|
|
minLongitude: -96.877,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|
|
|
|
const validate = createValidate(cfg);
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const client = createClient(dartProfile, 'public-transport/hafas-client:test');
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const mlkJrParkwayAdamsAve = '951013488'; // MARTIN LUTHER KING JR PKWY/ADAMS AVE
|
2021-08-24 18:58:24 +02:00
|
|
|
|
|
|
|
tap.test('locations named "martin luther kind adams"', async (t) => {
|
2024-02-06 22:58:49 +01:00
|
|
|
const locations = await client.locations('martin luther kind adams');
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
validate(t, locations, 'locations', 'locations');
|
2021-08-24 18:58:24 +02:00
|
|
|
t.ok(locations.some((l) => {
|
2024-02-06 22:58:49 +01:00
|
|
|
return l.station && l.station.id === mlkJrParkwayAdamsAve || l.id === mlkJrParkwayAdamsAve;
|
|
|
|
}), '"MARTIN LUTHER KING JR PKWY/ADAMS AVE" not found');
|
2021-08-24 18:58:24 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
t.end();
|
|
|
|
});
|