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

75 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

import tap from 'tap';
import {parseIcon as parse} from '../../parse/icon.js';
2019-09-03 15:35:12 +02:00
const ctx = {
data: {},
opt: {},
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 = {
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',
title: 'Berliner Verkehrsbetriebe',
});
2019-09-03 15:35:12 +02:00
const txtS = {
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',
title: '18',
});
2019-09-03 15:35:12 +02:00
const txt = {
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',
title: 'Regionalbus Braunschweig GmbH',
});
2019-09-03 15:35:12 +02:00
const noText = {
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',
title: null,
});
2019-09-03 15:35:12 +02:00
const withColor = {
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
},
};
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},
bgColor: {r: 0, g: 51, b: 153, a: 255},
});
const empty = {
res: 'Empty',
};
t.equal(parse(ctx, empty), null);
t.end();
});