-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest-setup.js
38 lines (35 loc) · 951 Bytes
/
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
"use strict";
const stylelint = require("stylelint");
const makeConfig = (options, code) => ({
config: {
plugins: ["./src/stylelint-require-units.js"],
rules: {
"matterialize/stylelint-require-units": options,
},
},
code,
syntax: "css-in-js",
});
global.runTests = ({ options, accept, reject }) => {
accept.forEach(({ it: itText, code }) => {
it(itText, () => (
stylelint
.lint(makeConfig(options, code))
.then(({ results }) => {
expect(results[0].warnings[0]).toBeUndefined();
})
));
});
reject.forEach(({ it: itText, code, text, line, column }) => {
it(itText, () => (
stylelint
.lint(makeConfig(options, code))
.then(({ results }) => {
const error = results[0].warnings[0];
expect(error.text).toBe(text);
expect(error.line).toBe(line);
expect(error.column).toBe(column);
})
));
});
};