Skip to content

Commit f0f1c70

Browse files
committed
Add unit tests for the config
1 parent f771d66 commit f0f1c70

File tree

3 files changed

+337
-0
lines changed

3 files changed

+337
-0
lines changed

src/__snapshots__/semver.test.js.snap

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`semver - should those tests break, consider releasing a new major version of the package config contents 1`] = `
4+
Object {
5+
"at-rule-empty-line-before": null,
6+
"at-rule-name-case": null,
7+
"at-rule-name-newline-after": null,
8+
"at-rule-name-space-after": Array [
9+
"always",
10+
],
11+
"at-rule-no-unknown": null,
12+
"at-rule-no-vendor-prefix": Array [
13+
true,
14+
],
15+
"at-rule-semicolon-newline-after": null,
16+
"at-rule-semicolon-space-before": Array [
17+
"never",
18+
],
19+
"block-closing-brace-empty-line-before": null,
20+
"block-closing-brace-newline-after": null,
21+
"block-closing-brace-newline-before": null,
22+
"block-closing-brace-space-after": null,
23+
"block-closing-brace-space-before": null,
24+
"block-no-empty": Array [
25+
true,
26+
],
27+
"block-opening-brace-newline-after": null,
28+
"block-opening-brace-newline-before": null,
29+
"block-opening-brace-space-after": null,
30+
"block-opening-brace-space-before": null,
31+
"color-hex-case": null,
32+
"color-hex-length": Array [
33+
"short",
34+
],
35+
"color-named": Array [
36+
"never",
37+
],
38+
"color-no-invalid-hex": Array [
39+
true,
40+
],
41+
"comment-empty-line-before": Array [
42+
"always",
43+
Object {
44+
"except": Array [
45+
"first-nested",
46+
],
47+
"ignore": Array [
48+
"stylelint-commands",
49+
],
50+
},
51+
],
52+
"comment-no-empty": Array [
53+
true,
54+
],
55+
"comment-whitespace-inside": Array [
56+
"always",
57+
],
58+
"custom-property-empty-line-before": Array [
59+
"always",
60+
Object {
61+
"except": Array [
62+
"after-custom-property",
63+
"first-nested",
64+
],
65+
"ignore": Array [
66+
"after-comment",
67+
"inside-single-line-block",
68+
],
69+
},
70+
],
71+
"declaration-bang-space-after": Array [
72+
"never",
73+
],
74+
"declaration-bang-space-before": Array [
75+
"always",
76+
],
77+
"declaration-block-no-duplicate-properties": Array [
78+
true,
79+
Object {
80+
"ignore": Array [
81+
"consecutive-duplicates-with-different-values",
82+
],
83+
},
84+
],
85+
"declaration-block-no-shorthand-property-overrides": Array [
86+
true,
87+
],
88+
"declaration-block-semicolon-newline-after": null,
89+
"declaration-block-semicolon-newline-before": null,
90+
"declaration-block-semicolon-space-after": null,
91+
"declaration-block-semicolon-space-before": null,
92+
"declaration-block-single-line-max-declarations": Array [
93+
1,
94+
],
95+
"declaration-block-trailing-semicolon": null,
96+
"declaration-colon-newline-after": null,
97+
"declaration-colon-space-after": null,
98+
"declaration-colon-space-before": null,
99+
"declaration-empty-line-before": null,
100+
"declaration-no-important": Array [
101+
true,
102+
],
103+
"font-family-no-duplicate-names": Array [
104+
true,
105+
],
106+
"font-family-no-missing-generic-family-keyword": Array [
107+
true,
108+
],
109+
"function-calc-no-invalid": Array [
110+
true,
111+
],
112+
"function-calc-no-unspaced-operator": Array [
113+
true,
114+
],
115+
"function-comma-newline-after": null,
116+
"function-comma-newline-before": null,
117+
"function-comma-space-after": null,
118+
"function-comma-space-before": null,
119+
"function-linear-gradient-no-nonstandard-direction": Array [
120+
true,
121+
],
122+
"function-max-empty-lines": null,
123+
"function-name-case": Array [
124+
"lower",
125+
],
126+
"function-parentheses-newline-inside": null,
127+
"function-parentheses-space-inside": null,
128+
"function-whitespace-after": Array [
129+
"always",
130+
],
131+
"indentation": null,
132+
"keyframe-declaration-no-important": Array [
133+
true,
134+
],
135+
"length-zero-no-unit": Array [
136+
true,
137+
],
138+
"max-empty-lines": null,
139+
"max-line-length": null,
140+
"max-nesting-depth": Array [
141+
4,
142+
],
143+
"media-feature-colon-space-after": Array [
144+
"always",
145+
],
146+
"media-feature-colon-space-before": Array [
147+
"never",
148+
],
149+
"media-feature-name-case": null,
150+
"media-feature-name-no-unknown": Array [
151+
true,
152+
],
153+
"media-feature-name-no-vendor-prefix": Array [
154+
true,
155+
],
156+
"media-feature-parentheses-space-inside": Array [
157+
"never",
158+
],
159+
"media-feature-range-operator-space-after": Array [
160+
"always",
161+
],
162+
"media-feature-range-operator-space-before": Array [
163+
"always",
164+
],
165+
"media-query-list-comma-newline-after": null,
166+
"media-query-list-comma-newline-before": null,
167+
"media-query-list-comma-space-after": null,
168+
"media-query-list-comma-space-before": null,
169+
"no-descending-specificity": null,
170+
"no-duplicate-at-import-rules": Array [
171+
true,
172+
],
173+
"no-duplicate-selectors": Array [
174+
true,
175+
],
176+
"no-empty-source": Array [
177+
true,
178+
],
179+
"no-eol-whitespace": null,
180+
"no-extra-semicolons": null,
181+
"no-invalid-double-slash-comments": Array [
182+
true,
183+
],
184+
"no-missing-end-of-source-newline": null,
185+
"number-leading-zero": null,
186+
"number-no-trailing-zeros": null,
187+
"property-case": null,
188+
"property-no-unknown": Array [
189+
true,
190+
],
191+
"property-no-vendor-prefix": Array [
192+
true,
193+
],
194+
"rule-empty-line-before": null,
195+
"scss/at-mixin-argumentless-call-parentheses": Array [
196+
"always",
197+
],
198+
"scss/at-rule-no-unknown": Array [
199+
true,
200+
],
201+
"scss/declaration-nested-properties": Array [
202+
"never",
203+
],
204+
"scss/dollar-variable-no-missing-interpolation": Array [
205+
true,
206+
],
207+
"scss/media-feature-value-dollar-variable": Array [
208+
"always",
209+
],
210+
"scss/percent-placeholder-pattern": Array [
211+
"^do-not-use-placeholders$",
212+
],
213+
"scss/selector-no-redundant-nesting-selector": Array [
214+
true,
215+
],
216+
"selector-attribute-brackets-space-inside": Array [
217+
"never",
218+
],
219+
"selector-attribute-operator-space-after": Array [
220+
"never",
221+
],
222+
"selector-attribute-operator-space-before": Array [
223+
"never",
224+
],
225+
"selector-attribute-quotes": Array [
226+
"always",
227+
],
228+
"selector-combinator-space-after": null,
229+
"selector-combinator-space-before": null,
230+
"selector-descendant-combinator-no-non-space": null,
231+
"selector-list-comma-newline-after": null,
232+
"selector-list-comma-newline-before": null,
233+
"selector-list-comma-space-after": null,
234+
"selector-list-comma-space-before": null,
235+
"selector-max-empty-lines": null,
236+
"selector-max-id": Array [
237+
0,
238+
],
239+
"selector-max-specificity": Array [
240+
"0,4,0",
241+
],
242+
"selector-max-type": Array [
243+
2,
244+
],
245+
"selector-no-vendor-prefix": Array [
246+
true,
247+
],
248+
"selector-pseudo-class-case": null,
249+
"selector-pseudo-class-no-unknown": Array [
250+
true,
251+
],
252+
"selector-pseudo-class-parentheses-space-inside": Array [
253+
"never",
254+
],
255+
"selector-pseudo-element-case": null,
256+
"selector-pseudo-element-colon-notation": Array [
257+
"double",
258+
],
259+
"selector-pseudo-element-no-unknown": Array [
260+
true,
261+
],
262+
"selector-type-case": Array [
263+
"lower",
264+
],
265+
"selector-type-no-unknown": Array [
266+
true,
267+
],
268+
"string-no-newline": Array [
269+
true,
270+
],
271+
"string-quotes": null,
272+
"unit-case": null,
273+
"unit-no-unknown": Array [
274+
true,
275+
],
276+
"value-list-comma-newline-after": null,
277+
"value-list-comma-newline-before": null,
278+
"value-list-comma-space-after": null,
279+
"value-list-comma-space-before": null,
280+
"value-list-max-empty-lines": null,
281+
"value-no-vendor-prefix": Array [
282+
true,
283+
],
284+
}
285+
`;

src/config.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const path = require('path');
2+
const stylelint = require('stylelint');
3+
4+
jest.setTimeout(15000);
5+
6+
describe('config', () => {
7+
it('works', () => {
8+
return stylelint
9+
.lint({
10+
code:
11+
'div.this #should .cause .issues:before { display: block !important; color: red; }',
12+
codeFilename: 'styles.css',
13+
configFile: path.join(__dirname, '..', 'config.js'),
14+
})
15+
.then((results) => {
16+
expect(results.results[0].warnings.length).toBe(6);
17+
});
18+
});
19+
});

src/semver.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const path = require('path');
2+
const stylelint = require('stylelint');
3+
4+
const pkg = require('../package.json');
5+
6+
describe('semver - should those tests break, consider releasing a new major version of the package', () => {
7+
it('dependencies', () => {
8+
expect(pkg.dependencies).toMatchInlineSnapshot(`
9+
Object {
10+
"stylelint-config-prettier": "^5.2.0",
11+
"stylelint-config-standard": "^18.3.0",
12+
"stylelint-scss": "^3.10.0",
13+
}
14+
`);
15+
});
16+
17+
it('peerDependencies', () => {
18+
expect(pkg.peerDependencies).toMatchInlineSnapshot(`
19+
Object {
20+
"stylelint": "^10.1.0",
21+
}
22+
`);
23+
});
24+
25+
it('config contents', () => {
26+
const linter = stylelint.createLinter({
27+
configFile: path.join(__dirname, '..', 'config.js'),
28+
});
29+
return linter.getConfigForFile().then((result) => {
30+
expect(result.config.rules).toMatchSnapshot();
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)