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

77 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2019-09-03 15:35:12 +02:00
'use strict'
2021-05-20 16:42:43 +01:00
const tap = require('tap')
2019-09-03 15:35:12 +02:00
const parse = require('../../parse/icon')
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'
})
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'
})
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'
})
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
})
const withColor = {
"res": "prod_sub_t",
"fg": {
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"bg": {
"r": 0,
"g": 51,
"b": 153,
"a": 255
}
}
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)
2019-09-03 15:35:12 +02:00
t.end()
})