-
Notifications
You must be signed in to change notification settings - Fork 10
/
jest.setup.js
47 lines (40 loc) · 1.27 KB
/
jest.setup.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
import { getTestRule } from 'jest-preset-stylelint';
import { lint } from 'stylelint';
// eslint-disable-next-line import/extensions
import declarationStrictValuePlugin from './src/index.ts';
const plugins = [declarationStrictValuePlugin];
global.testRule = getTestRule({ plugins });
global.testCustomAutoFixMessage = testCustomAutoFixMessage;
function testCustomAutoFixMessage({ ruleName, config, reject, fix }) {
// eslint-disable-next-line no-undef
describe(ruleName, () => {
// eslint-disable-next-line no-undef
it('warn for invalid options', async () => {
const rejections = await Promise.all(
reject.map(async ({ code, message }) => {
const {
results: [{ warnings }],
} = await lint({
fix,
code,
config: {
plugins,
rules: {
[ruleName]: config,
},
},
quietDeprecationWarnings: true,
});
return { message, warnings };
})
);
rejections.forEach(({ message, warnings }) => {
const expectedWarning = {
text: message,
};
// eslint-disable-next-line no-undef
expect(warnings[0]).toMatchObject(expectedWarning);
});
});
});
}