/
declaration-bang-space-before.test.mjs
50 lines (41 loc) · 1.13 KB
/
declaration-bang-space-before.test.mjs
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
import { beforeEach, describe, it } from 'node:test';
import assert from 'node:assert/strict';
import stylelint from 'stylelint';
import config from '../index.js';
describe('flags warnings with declaration-bang-space-before lint', () => {
const invalidScss = (
`.test-selector { color: #fff!important; }
.test-selector { color: #fff !important; }
`);
let result;
beforeEach(async () => {
result = await stylelint.lint({
code: invalidScss,
config,
});
});
it('did error', () => {
assert.equal(result.errored, true);
});
it('flags warnings', () => {
assert.equal(result.results[0].warnings.length, 2);
});
it('correct warning text', () => {
assert.deepEqual(
result.results[0].warnings.map((w) => w.text),
[
'Expected single space before "!" (@stylistic/declaration-bang-space-before)',
'Expected single space before "!" (@stylistic/declaration-bang-space-before)',
],
);
});
it('correct rule flagged', () => {
assert.deepEqual(
result.results[0].warnings.map((w) => w.rule),
[
'@stylistic/declaration-bang-space-before',
'@stylistic/declaration-bang-space-before',
],
);
});
});