-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
Copy patheslintMigrator.spec.js
64 lines (53 loc) · 1.63 KB
/
eslintMigrator.spec.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
jest.setTimeout(300000)
jest.mock('inquirer')
const create = require('@vue/cli-test-utils/createUpgradableProject')
const { expectPrompts } = require('inquirer')
test('upgrade: should add eslint to devDependencies', async () => {
const project = await create('plugin-eslint-v3.0', {
plugins: {
'@vue/cli-plugin-eslint': {
version: '3.0.0'
}
}
})
const pkg = JSON.parse(await project.read('package.json'))
expect(pkg.devDependencies).not.toHaveProperty('eslint')
expectPrompts([
{
message: `Your current ESLint version is v4`,
confirm: false
}
])
await project.upgrade('eslint')
const updatedPkg = JSON.parse(await project.read('package.json'))
expect(updatedPkg.devDependencies.eslint).toMatch('^4')
})
test('upgrade: should upgrade eslint from v5 to v6', async () => {
const project = await create('plugin-eslint-with-eslint-5', {
plugins: {
'@vue/cli-plugin-eslint': {
version: '3.12.1',
config: 'airbnb'
}
}
})
const pkg = JSON.parse(await project.read('package.json'))
expect(pkg.devDependencies.eslint).toMatch('^5')
expectPrompts([
{
message: `Your current ESLint version is v5`,
confirm: true
}
])
try {
await project.upgrade('eslint')
} catch (e) {
// TODO:
// Currently the `afterInvoke` hook will fail,
// because deps are not correctly installed in test env.
// Need to fix later.
}
const updatedPkg = JSON.parse(await project.read('package.json'))
expect(updatedPkg.devDependencies.eslint).toMatch('^6')
expect(updatedPkg.devDependencies).toHaveProperty('eslint-plugin-import')
})