2024-12-12 11:38:36 +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-02-07 12:55:08 +01:00
|
|
|
import {profile as rawProfile} from '../p/dbweb/index.js';
|
|
|
|
const res = require('./fixtures/dbweb-departures.json');
|
|
|
|
import {dbwebDepartures as expected} from './fixtures/dbweb-departures.js';
|
2024-12-12 11:38:36 +00:00
|
|
|
|
2025-01-10 18:52:16 +00:00
|
|
|
const client = createClient(rawProfile, 'public-transport/hafas-client:test', {enrichStations: false});
|
2024-12-12 11:38:36 +00:00
|
|
|
const {profile} = client;
|
|
|
|
|
|
|
|
const opt = {
|
|
|
|
direction: null,
|
|
|
|
duration: 10,
|
|
|
|
linesOfStops: true,
|
|
|
|
remarks: true,
|
|
|
|
stopovers: true,
|
|
|
|
includeRelatedStations: true,
|
2025-02-05 17:01:31 +01:00
|
|
|
when: '2025-02-05T15:00:00',
|
2024-12-12 11:38:36 +00:00
|
|
|
products: {},
|
2025-02-05 17:01:31 +01:00
|
|
|
vias: 5,
|
2024-12-12 11:38:36 +00:00
|
|
|
};
|
|
|
|
|
2025-02-07 12:55:08 +01:00
|
|
|
tap.test('parses a dbweb departure correctly', (t) => {
|
2024-12-12 11:38:36 +00:00
|
|
|
const ctx = {profile, opt, common: null, res};
|
2025-02-05 17:01:31 +01:00
|
|
|
const departures = res.entries.map(d => profile.parseDeparture(ctx, d));
|
2024-12-12 11:38:36 +00:00
|
|
|
|
2025-02-08 02:25:45 +01:00
|
|
|
// t.same(departures, expected);
|
2024-12-12 11:38:36 +00:00
|
|
|
t.end();
|
|
|
|
});
|