This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest.js
101 lines (86 loc) · 2.39 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
const {expect} = require('chai');
const ESLinter = require('.');
const data = 'with (a) eval(b)';
const createPlugin = eslint => {
return new ESLinter({
plugins: {eslint},
});
};
describe('eslint-brunch', () => {
it('should be an object', () => {
expect(createPlugin()).to.be.instanceof(ESLinter);
});
it('should have `lint` method', () => {
expect(createPlugin()).to.respondTo('lint');
});
describe('config', () => {
it('should use `.eslintrc` by default', () => {
expect(() => {
createPlugin().lint({data});
}).to.throw('2 errors');
});
it('should override `.eslintrc`', () => {
expect(() => {
createPlugin({
config: {
rules: {
'no-with': 'off',
},
},
}).lint({data});
}).to.throw('1 error');
expect(() => {
createPlugin({
config: {
rules: {
'no-eval': 'off',
'no-with': 'off',
},
},
}).lint({data});
}).not.to.throw();
});
});
describe('pattern', () => {
it('should ignore `node_modules` by default', () => {
expect('node_modules/file.js').not.to.match(createPlugin().pattern);
});
it('should match `.js` files by default', () => {
expect('app/file.js').to.match(createPlugin().pattern);
});
it('should match `.jsx` files by default', () => {
expect('app/file.jsx').to.match(createPlugin().pattern);
});
it('should be configurable', () => {
expect('app/file.mjs').to.match(createPlugin({pattern: /\.mjs$/}).pattern);
});
});
describe('formatter', () => {
it('should default to `stylish`', () => {
expect(() => {
createPlugin().lint({data});
}).to.throw('✖');
});
it('should be configurable', () => {
expect(() => {
createPlugin({formatter: 'table'}).lint({data});
}).to.throw('╔');
expect(() => {
createPlugin({formatter: 'html'}).lint({data});
}).to.throw('<!DOCTYPE html>');
});
});
describe('warnOnly', () => {
it('should default to `true`', () => {
expect(() => {
createPlugin().lint({data});
}).to.throw(/^warn:/);
});
it('should be configurable', () => {
expect(() => {
createPlugin({warnOnly: false}).lint({data});
}).to.throw(/^ESLint/);
});
});
});