2024-02-06 22:58:49 +01:00
|
|
|
import tap from 'tap';
|
|
|
|
import {parseIcon as parse} from '../../parse/icon.js';
|
2019-09-03 15:35:12 +02:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
const ctx = {
|
|
|
|
data: {},
|
|
|
|
opt: {},
|
2024-02-06 22:58:49 +01:00
|
|
|
profile: {},
|
|
|
|
};
|
2019-09-03 15:35:12 +02:00
|
|
|
|
2021-05-20 16:42:43 +01:00
|
|
|
tap.test('parses icons correctly', (t) => {
|
2019-09-03 15:35:12 +02:00
|
|
|
const text = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'BVG',
|
|
|
|
text: 'Berliner Verkehrsbetriebe',
|
|
|
|
};
|
2021-05-20 16:42:43 +01:00
|
|
|
t.same(parse(ctx, text), {
|
2019-09-03 15:35:12 +02:00
|
|
|
type: 'BVG',
|
2024-02-06 22:58:49 +01:00
|
|
|
title: 'Berliner Verkehrsbetriebe',
|
|
|
|
});
|
2019-09-03 15:35:12 +02:00
|
|
|
|
|
|
|
const txtS = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'PROD_BUS',
|
|
|
|
txtS: '18',
|
|
|
|
};
|
2021-05-20 16:42:43 +01:00
|
|
|
t.same(parse(ctx, txtS), {
|
2019-09-03 15:35:12 +02:00
|
|
|
type: 'PROD_BUS',
|
2024-02-06 22:58:49 +01:00
|
|
|
title: '18',
|
|
|
|
});
|
2019-09-03 15:35:12 +02:00
|
|
|
|
|
|
|
const txt = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'RBB',
|
|
|
|
txt: 'Regionalbus Braunschweig GmbH',
|
|
|
|
};
|
2021-05-20 16:42:43 +01:00
|
|
|
t.same(parse(ctx, txt), {
|
2019-09-03 15:35:12 +02:00
|
|
|
type: 'RBB',
|
2024-02-06 22:58:49 +01:00
|
|
|
title: 'Regionalbus Braunschweig GmbH',
|
|
|
|
});
|
2019-09-03 15:35:12 +02:00
|
|
|
|
|
|
|
const noText = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'attr_bike_r',
|
|
|
|
};
|
2021-05-20 16:42:43 +01:00
|
|
|
t.same(parse(ctx, noText), {
|
2019-09-03 15:35:12 +02:00
|
|
|
type: 'attr_bike_r',
|
2024-02-06 22:58:49 +01:00
|
|
|
title: null,
|
|
|
|
});
|
2019-09-03 15:35:12 +02:00
|
|
|
|
|
|
|
const withColor = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'prod_sub_t',
|
|
|
|
fg: {
|
|
|
|
r: 255,
|
|
|
|
g: 255,
|
|
|
|
b: 255,
|
|
|
|
a: 255,
|
|
|
|
},
|
|
|
|
bg: {
|
|
|
|
r: 0,
|
|
|
|
g: 51,
|
|
|
|
b: 153,
|
|
|
|
a: 255,
|
2019-09-03 15:35:12 +02:00
|
|
|
},
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|
2021-05-20 16:42:43 +01:00
|
|
|
t.same(parse(ctx, withColor), {
|
2019-09-03 15:35:12 +02:00
|
|
|
type: 'prod_sub_t',
|
|
|
|
title: null,
|
|
|
|
fgColor: {r: 255, g: 255, b: 255, a: 255},
|
2024-02-06 22:58:49 +01:00
|
|
|
bgColor: {r: 0, g: 51, b: 153, a: 255},
|
|
|
|
});
|
2020-03-18 21:37:31 +01:00
|
|
|
|
|
|
|
const empty = {
|
2024-02-06 22:58:49 +01:00
|
|
|
res: 'Empty',
|
|
|
|
};
|
|
|
|
t.equal(parse(ctx, empty), null);
|
2020-03-18 21:37:31 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
t.end();
|
|
|
|
});
|