-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.tape.js
107 lines (89 loc) · 3.22 KB
/
.tape.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
const test = require('stylelint-test-rule-tape');
const { default: { rule }, ruleName } = require('.');
const skipBasicChecks = true;
let accept = [], reject = [];
/* Test basic checks
/* ========================================================================== */
test(rule, { ruleName, config: null });
test(rule, { ruleName, config: false });
test(rule, { ruleName, config: true });
/* Test disabled
/* ========================================================================== */
accept = [
{ code: 'body { color: var(--brand-blue); }', description: 'ignored custom property' }
];
test(rule, { ruleName, skipBasicChecks, config: null, accept });
test(rule, { ruleName, skipBasicChecks, config: false, accept });
/* Test enabled
/* ========================================================================== */
accept = [
{ code: 'body { --brand-blue: #33f; color: var(--brand-blue); }' },
{ code: ':root { --brand-blue: #33f; } body { color: var(--brand-blue); }' },
{ code: 'html { --brand-blue: #33f; } body { color: var(--brand-blue); }' },
{ code: '* { --brand-blue: #33f; } body { color: var(--brand-blue); }' },
{ code: '.anything { --brand-blue: #33f; } body { color: var(--brand-blue); }' },
{ code: ':root { --brand-blue: #33f; --brand-color: var(--brand-blue); }' },
{ code: "@import './test/import-custom-properties.css'; body { color: var(--brand-red); }"},
{ code: "@import './test/import-custom-properties.css'; @import './test/import-custom-properties123.css'; body { color: var(--brand-red); }"}
];
reject = [
{ code: 'body { color: var(--brand-blue); }' },
{ code: "@import './test/import-custom-properties123.css'; body { color: var(--brand-red); }"}
];
test(rule, { ruleName, skipBasicChecks, config: true, accept, reject });
/* Test fallbacks
/* ========================================================================== */
accept = [
{ code: 'body { color: var(--brand-blue, #33f); }' }
];
reject = [
{ code: 'body { color: var(--brand-blue, var(--brand-red)); }' }
];
test(rule, { ruleName, skipBasicChecks, config: true, accept, reject });
/* Test enabled: not var()s
/* ========================================================================== */
accept = [
{ code: 'body { color: brand-blue; }' },
{ code: 'body { color: var(); }' }
];
test(rule, { ruleName, skipBasicChecks, config: true, accept });
/* Test enabled: { importFrom }
/* ========================================================================== */
accept = [
{ code: 'body { color: var(--brand-blue); }' }
];
reject = [
{ code: 'body { color: var(--brand-blu); }' },
{ code: 'body { color: var(--brand-bluez); }' }
];
test(rule, {
ruleName,
config: [true, {
importFrom: {
customProperties: {
'--brand-blue': '#fff'
}
}
}],
skipBasicChecks
});
accept = [
{ code: 'body { background-color: var(--brand-red); background: var(--brand-green); border-color: var(--brand-white); color: var(--brand-blue); }' }
];
reject = [
{ code: 'body { color: var(--brand-blu); }' },
{ code: 'body { color: var(--brand-bluez); }' }
];
test(rule, {
ruleName,
config: [true, {
importFrom: [
'test/import-custom-properties.js',
'test/import-custom-properties.json',
'test/import-custom-properties.css'
]
}],
skipBasicChecks,
accept,
reject
});