-
Notifications
You must be signed in to change notification settings - Fork 7
/
stylelint.config.test.js
61 lines (51 loc) · 1.5 KB
/
stylelint.config.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
/* eslint-env jest */
const stylelintConfig = require('./stylelint.config');
function testCadsPattern(pattern) {
const regex = new RegExp(pattern);
const validNames = ['cads-prefixed'];
validNames.forEach((name) => {
expect(regex.test(name)).toBeTruthy();
});
const invalidNames = [
'no-prefix',
'cadsButIncorrectCase',
'just__dOwNrIGht--Odd',
];
invalidNames.forEach((name) => {
expect(regex.test(name)).toBeFalsy();
});
}
test('scss/at-function-pattern', () => {
testCadsPattern(stylelintConfig.rules['scss/at-function-pattern']);
});
test('scss/at-mixin-pattern', () => {
testCadsPattern(stylelintConfig.rules['scss/at-mixin-pattern']);
});
test('scss/dollar-variable-pattern', () => {
testCadsPattern(stylelintConfig.rules['scss/dollar-variable-pattern'][0]);
});
test('scss/percent-placeholder-pattern', () => {
testCadsPattern(stylelintConfig.rules['scss/percent-placeholder-pattern'][0]);
});
test('selector-class-pattern', () => {
const regex = new RegExp(stylelintConfig.rules['selector-class-pattern'][0]);
const validNames = [
'cads-prefixed',
'cads-prefixed__child',
'cads-prefixed--modifier',
'cads-prefixed-number-1',
// No JavaScript class is special cased
'no-js',
];
validNames.forEach((name) => {
expect(regex.test(name)).toBeTruthy();
});
const invalidNames = [
'no-prefix',
'cadsButIncorrectCase',
'just__dOwNrIGht--Odd',
];
invalidNames.forEach((name) => {
expect(regex.test(name)).toBeFalsy();
});
});