-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
executable file
·108 lines (96 loc) · 2.28 KB
/
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import postcss from 'postcss';
import test from 'ava';
import plugin from './lib/';
function run(t, input, output, opts = { }) {
return postcss([ plugin(opts) ]).process(input)
.then( result => {
t.regex(result.css, output);
t.deepEqual(result.warnings().length, 0);
});
}
test('uses randomColor keyword in color prop', t => {
return run(
t,
'a{color: randomColor}',
/a{color: #[0-9a-f]{6}}/,
{ }
);
});
test('uses randomColor keyword in border prop', t => {
return run(
t,
'a{border: 1px solid randomColor}',
/a{border: 1px solid #[0-9a-f]{6}}/,
{ }
);
});
test('uses randomColor function without params', t => {
return run(
t,
'a{color: randomColor()}',
/a{color: #[0-9a-f]{6}}/,
{ }
);
});
test('uses randomColor function with params (luminosity and hue)', t => {
return run(
t,
'a{color: randomColor(bright, green)}',
/a{color: #[0-9a-f]{6}}/,
{ }
);
});
test('uses randomColor as variable', t => {
return run(
t,
'$color: randomColor(dark)',
/\$color: #[0-9a-f]{6}/,
{ }
);
});
test('uses randomColor keyword in function', t => {
return run(
t,
'a{color: color(randomColor a(.5))}',
/\a{color: color\(#[0-9a-f]{6} a\(\.5\)\)}/,
{ }
);
});
test('uses randomColor function in function', t => {
return run(
t,
'a{color: color(randomColor(dark, red) a(.5))}',
/\a{color: color\(#[0-9a-f]{6} a\(\.5\)\)}/,
{ }
);
});
test('uses randomColor with another keyword', t => {
return run(
t,
'a{color: random-color}',
/a{color: #[0-9a-f]{6}}/,
{
functionName: 'random-color'
}
);
});
test('uses randomColor with rgb format', t => {
return run(
t,
'a{color: randomColor}',
/a{color: rgb\(\d{1,3}, \d{1,3}, \d{1,3}\)}/,
{
format: 'rgb'
}
);
});
test('uses randomColor with hsl format', t => {
return run(
t,
'a{color: randomColor}',
/a{color: hsl\(\d{1,3}, (?:\d*\.)?\d+%, (?:\d*\.)?\d+%\)/,
{
format: 'hsl'
}
);
});