2022-05-07 16:17:37 +02: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: {},
|
|
|
|
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}
|
|
|
|
})
|
2020-03-18 21:37:31 +01:00
|
|
|
|
|
|
|
const empty = {
|
|
|
|
"res": "Empty"
|
|
|
|
}
|
|
|
|
t.equal(parse(ctx, empty), null)
|
|
|
|
|
2019-09-03 15:35:12 +02:00
|
|
|
t.end()
|
|
|
|
})
|