-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
31 lines (24 loc) · 1.05 KB
/
index.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
const { ESLint } = require('eslint')
const config = require('./index.js')
const WARNING_REACT_VERSION_WAS_SET_TO_DETECT =
'Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.'
const TINY_VALID_JS_CODE = ''
const error = jest.spyOn(console, 'error').mockImplementation(() => {})
afterAll(() => {
error.mockRestore()
})
describe('Validate ESLint config', () => {
const eslint = new ESLint({ overrideConfig: config })
it(`all top-level properties are correct`, async () => {
const [result] = await eslint.lintText(TINY_VALID_JS_CODE)
expect(result.messages.length).toBe(0)
})
it(`no react package is installed warning`, async () => {
await eslint.lintText(TINY_VALID_JS_CODE)
expect(error).toHaveBeenCalledWith(WARNING_REACT_VERSION_WAS_SET_TO_DETECT)
})
it(`no deprecated rules are used`, async () => {
const [result] = await eslint.lintText(TINY_VALID_JS_CODE)
expect(result.usedDeprecatedRules.length).toBe(0)
})
})