db-vendo-client/test/parse/operator.js

53 lines
971 B
JavaScript
Raw Normal View History

import tap from 'tap';
import {parseOperator as parse} from '../../parse/operator.js';
2019-09-03 15:35:12 +02:00
const ctx = {
data: {},
opt: {},
profile: {},
};
2024-12-07 16:16:31 +00:00
2021-05-20 16:42:43 +01:00
tap.test('parses an operator correctly', (t) => {
2024-12-07 16:16:31 +00:00
const op = [{
2024-12-08 21:42:57 +00:00
kategorie: 'BEFÖRDERER',
key: 'BEF',
value: 'DB Fernverkehr AG',
}, {
kategorie: 'FAHRRADMITNAHME',
key: 'FR',
value: 'Bicycles conveyed - subject to reservation',
2024-12-07 16:16:31 +00:00
}];
2019-09-03 15:35:12 +02:00
2021-05-20 16:42:43 +01:00
t.same(parse(ctx, op), {
2019-09-03 15:35:12 +02:00
type: 'operator',
2024-12-07 16:16:31 +00:00
id: 'db-fernverkehr-ag',
name: 'DB Fernverkehr AG',
});
t.end();
});
2024-12-07 16:16:31 +00:00
tap.test('parses nothing', (t) => {
const op = [{
2024-12-08 21:42:57 +00:00
kategorie: 'INFORMATION',
key: 'cB',
value: 'Tel. 0981-9714925, Anmeldung bis 90 Min. vor Abfahrt (Mo-So: 9-15 Uhr)',
2024-12-07 16:16:31 +00:00
}];
t.same(parse(ctx, op), null);
t.end();
});
2025-01-02 14:00:45 +00:00
tap.test('parses dbnav operator correctly', (t) => {
const op = [{text: 'DB Fernverkehr AG', key: 'OP'}];
t.same(parse(ctx, op), {
type: 'operator',
id: 'db-fernverkehr-ag',
name: 'DB Fernverkehr AG',
});
t.end();
});