/
standalone-invalidScopeDisables.test.js
51 lines (45 loc) · 1.46 KB
/
standalone-invalidScopeDisables.test.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
48
49
50
51
'use strict';
const path = require('path');
const replaceBackslashes = require('./replaceBackslashes');
const standalone = require('../standalone');
const fixturesPath = replaceBackslashes(path.join(__dirname, 'fixtures'));
const config = {
quiet: true,
rules: {
'block-no-empty': true,
},
};
it('standalone with input css and `reportInvalidScopeDisables`', () => {
return standalone({
code: '/* stylelint-disable color-named */\na {}',
config,
reportInvalidScopeDisables: true,
}).then((linted) => {
const invalidScopeDisables = linted.invalidScopeDisables;
expect(typeof invalidScopeDisables).toBe('object');
expect(invalidScopeDisables).toHaveLength(1);
expect(invalidScopeDisables[0].ranges).toHaveLength(1);
expect(invalidScopeDisables[0].ranges[0]).toEqual({
start: 1,
unusedRule: 'color-named',
});
});
});
it('standalone with input file(s) and `reportInvalidScopeDisables`', () => {
return standalone({
files: replaceBackslashes(path.join(fixturesPath, 'empty-block-with-disables.css')),
config,
reportInvalidScopeDisables: true,
}).then((linted) => {
const invalidScopeDisables = linted.invalidScopeDisables;
expect(typeof invalidScopeDisables).toBe('object');
expect(invalidScopeDisables).toHaveLength(1);
expect(invalidScopeDisables[0].source).toBe(
path.join(fixturesPath, 'empty-block-with-disables.css'),
);
expect(invalidScopeDisables[0].ranges[0]).toEqual({
start: 1,
unusedRule: 'color-named',
});
});
});