-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathlchuv.test.js
65 lines (61 loc) · 1.31 KB
/
lchuv.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import test from 'node:test';
import assert from 'node:assert';
import { lchuv, rgb, formatCss } from '../src/index.js';
test('lchuv', t => {
assert.deepEqual(
lchuv('white'),
{
mode: 'lchuv',
l: 100.00000139649632,
c: 0.000013192899605235416,
h: 129.3684297210339
},
'white'
);
assert.deepEqual(lchuv('black'), { mode: 'lchuv', l: 0, c: 0 }, 'black');
assert.deepEqual(
lchuv('red'),
{
mode: 'lchuv',
l: 54.29054294696968,
c: 176.94953872495253,
h: 8.434231142939021
},
'red'
);
assert.deepEqual(
lchuv('#00cc0080'),
{
mode: 'lchuv',
l: 71.74973747305378,
c: 99.4709666171262,
h: 134.23124010020916,
alpha: 0.5019607843137255
},
'#00cc0080'
);
});
test('color(--lchuv)', t => {
assert.deepEqual(lchuv('color(--lchuv 30 0.5 1 / 0.25)'), {
l: 30,
c: 0.5,
h: 1,
alpha: 0.25,
mode: 'lchuv'
});
});
test('formatCss', t => {
assert.equal(
formatCss('color(--lchuv 30 0.5 1 / 0.25)'),
'color(--lchuv 30 0.5 1 / 0.25)'
);
});
test('missing components', t => {
assert.ok(rgb('color(--lchuv none 0.5 none)'), 'lchuv to rgb is ok');
assert.deepEqual(
rgb('color(--lchuv none 0.5 none)'),
rgb('color(--lchuv 0 0.5 0)')
);
assert.ok(lchuv('rgb(none 100 20)'), 'rgb to lchuv is ok');
assert.deepEqual(lchuv('rgb(none 100 20)'), lchuv('rgb(0 100 20)'));
});