Skip to content

Commit d6798df

Browse files
Started to split tests in separat files
1 parent 26a1793 commit d6798df

File tree

6 files changed

+149
-0
lines changed

6 files changed

+149
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
/* spacing */
3+
.avatar{
4+
line-height: 0.75; border-radius: 50%;
5+
border:2px solid white; }
6+
.name {
7+
border: none;
8+
}
9+
10+
/* multiple selectors */
11+
.no, .nope, .not_good { }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
/* ID selectors */
3+
#lol-no { }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
/* spacing */
3+
.avatar {
4+
line-height: .75;
5+
border-radius: 50%;
6+
border: 2px solid white;
7+
}
8+
9+
.name {
10+
border: 0;
11+
}
12+
13+
/* multiple selectors */
14+
.yes,
15+
.sure,
16+
.good { }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
/* OOCSS and BEM */
3+
.ListingCard { }
4+
5+
.ListingCard--featured { }
6+
7+
.ListingCard__title { }
8+
9+
.ListingCard__content { }
10+
11+
12+
/* tag selectors */
13+
a { }
14+
15+
/* attribute selectors */
16+
[aria-hidden] { }
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
import fs from 'fs';
3+
import stylelint from 'stylelint';
4+
import test from 'ava';
5+
import config from '../';
6+
7+
const good = fs.readFileSync('./test/good-formatting.css', 'utf-8');
8+
const bad = fs.readFileSync('./test/bad-formatting.css', 'utf-8');
9+
10+
test('Nothing wrong with good-formatting.css', t => {
11+
const isValid = stylelint.lint({
12+
code: good,
13+
config,
14+
})
15+
.then(data => {
16+
const { errored, results } = data;
17+
const { warnings } = results[0];
18+
19+
t.falsy(errored, 'no errored');
20+
21+
t.is(warnings.length, 0);
22+
});
23+
24+
return isValid;
25+
});
26+
27+
test('Warnings in bad-formatting.css', t => {
28+
const isValid = stylelint.lint({
29+
code: bad,
30+
config,
31+
})
32+
.then(data => {
33+
const { errored, results } = data;
34+
const { warnings } = results[0];
35+
36+
t.truthy(errored, 'errored');
37+
38+
t.is(warnings.length, 10);
39+
40+
t.is(warnings[0].text, 'Expected indentation of 2 spaces (indentation)');
41+
t.is(warnings[1].text, 'Expected indentation of 2 spaces (indentation)');
42+
t.is(warnings[2].text, 'Expected indentation of 2 spaces (indentation)');
43+
t.is(warnings[3].text, 'Unexpected leading zero (number-leading-zero)');
44+
t.is(warnings[4].text, 'Expected newline after "," (selector-list-comma-newline-after)');
45+
t.is(warnings[5].text, 'Expected newline after "," (selector-list-comma-newline-after)');
46+
t.is(
47+
warnings[6].text,
48+
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)'
49+
);
50+
t.is(warnings[7].text, 'Expected single space before "{" (block-opening-brace-space-before)');
51+
t.is(warnings[8].text, 'Expected single space after ":" (declaration-colon-space-after)');
52+
t.is(
53+
warnings[9].text,
54+
'Unexpected value "none" for property "border" (declaration-property-value-blacklist)'
55+
);
56+
});
57+
58+
return isValid;
59+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
import fs from 'fs';
3+
import stylelint from 'stylelint';
4+
import test from 'ava';
5+
import config from '../';
6+
7+
const good = fs.readFileSync('./test/good-selectors.css', 'utf-8');
8+
const bad = fs.readFileSync('./test/bad-selectors.css', 'utf-8');
9+
10+
test('Nothing wrong with good-selectors.css', t => {
11+
const isValid = stylelint.lint({
12+
code: good,
13+
config,
14+
})
15+
.then(data => {
16+
const { errored, results } = data;
17+
const { warnings } = results[0];
18+
19+
t.falsy(errored, 'no errored');
20+
21+
t.is(warnings.length, 0);
22+
});
23+
24+
return isValid;
25+
});
26+
27+
test('Warnings in bad-selectors.css', t => {
28+
const isValid = stylelint.lint({
29+
code: bad,
30+
config,
31+
})
32+
.then(data => {
33+
const { errored, results } = data;
34+
const { warnings } = results[0];
35+
36+
t.truthy(errored, 'errored');
37+
38+
t.is(warnings.length, 1);
39+
40+
t.is(warnings[0].text, 'Unexpected id selector (selector-no-id)');
41+
});
42+
43+
return isValid;
44+
});

0 commit comments

Comments
 (0)