2025-01-02 14:00:45 +00:00
|
|
|
// todo: use import assertions once they're supported by Node.js & ESLint
|
|
|
|
// https://github.com/tc39/proposal-import-assertions
|
|
|
|
import {createRequire} from 'module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
|
|
|
import tap from 'tap';
|
|
|
|
|
|
|
|
import {createClient} from '../index.js';
|
2025-01-08 23:02:57 +00:00
|
|
|
import {profile as rawProfile} from '../p/dbnav/index.js';
|
2025-01-02 14:00:45 +00:00
|
|
|
const res = require('./fixtures/dbnav-departures.json');
|
|
|
|
import {dbnavDepartures as expected} from './fixtures/dbnav-departures.js';
|
|
|
|
|
2025-01-10 18:52:16 +00:00
|
|
|
const client = createClient(rawProfile, 'public-transport/hafas-client:test', {enrichStations: false});
|
2025-01-02 14:00:45 +00:00
|
|
|
const {profile} = client;
|
|
|
|
|
|
|
|
const opt = {
|
|
|
|
direction: null,
|
|
|
|
duration: 10,
|
|
|
|
linesOfStops: true,
|
|
|
|
remarks: true,
|
|
|
|
stopovers: true,
|
|
|
|
includeRelatedStations: true,
|
|
|
|
when: '2019-08-19T20:30:00+02:00',
|
|
|
|
products: {},
|
|
|
|
};
|
|
|
|
|
2025-01-03 10:57:24 +00:00
|
|
|
tap.test('parses a dbnav departure correctly', (t) => {
|
2025-01-02 14:00:45 +00:00
|
|
|
const ctx = {profile, opt, common: null, res};
|
|
|
|
const departures = res.bahnhofstafelAbfahrtPositionen.map(d => profile.parseDeparture(ctx, d));
|
|
|
|
t.same(departures, expected);
|
|
|
|
t.end();
|
|
|
|
});
|