1 | import * as path from 'path'
|
2 |
|
3 | import validator from '../doctor/eslintValidator'
|
4 |
|
5 | describe('eslint validator of doctor', () => {
|
6 | let cwd = ''
|
7 | beforeEach(() => {
|
8 | cwd = process.cwd()
|
9 | })
|
10 |
|
11 | afterEach(() => {
|
12 | process.chdir(cwd)
|
13 | })
|
14 |
|
15 | it('should lint for react', async () => {
|
16 | process.chdir(path.join(__dirname, 'fixtures/default'))
|
17 | const raw = await validator({
|
18 | projectConfig: {
|
19 | framework: 'react',
|
20 | sourceRoot: 'src'
|
21 | }
|
22 | }).then(e => e.raw)
|
23 |
|
24 | expect(raw).toBe('')
|
25 | })
|
26 |
|
27 | it('should lint for nerv', async () => {
|
28 | process.chdir(path.join(__dirname, 'fixtures/nerv'))
|
29 | const raw = await validator({
|
30 | projectConfig: {
|
31 | framework: 'nerv',
|
32 | sourceRoot: 'src'
|
33 | }
|
34 | }).then(e => e.raw)
|
35 |
|
36 | expect(raw.includes('\'a\' is assigned a value but never used'))
|
37 | })
|
38 |
|
39 | it('should lint for vue', async () => {
|
40 | process.chdir(path.join(__dirname, 'fixtures/vue'))
|
41 | const raw = await validator({
|
42 | projectConfig: {
|
43 | framework: 'vue',
|
44 | sourceRoot: 'src'
|
45 | }
|
46 | }).then(e => e.raw)
|
47 |
|
48 | expect(raw).toBe('')
|
49 | })
|
50 | })
|