forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceESM.spec.js
33 lines (27 loc) · 1013 Bytes
/
ServiceESM.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
const { join } = require('path')
const Service = require('../lib/Service')
const mockDir = join(__dirname, 'mockESM')
const configPath = join(mockDir, 'vue.config.cjs')
const createService = () => {
const service = new Service(mockDir, {
plugins: [],
useBuiltIn: false
})
service.init()
return service
}
// vue.config.cjs has higher priority
test('load project options from package.json', async () => {
const service = createService()
expect(service.projectOptions.lintOnSave).toBe('default')
})
test('load project options from vue.config.cjs', async () => {
jest.mock(configPath, () => ({ lintOnSave: true }), { virtual: true })
const service = createService()
expect(service.projectOptions.lintOnSave).toBe(true)
})
test('load project options from vue.config.cjs as a function', async () => {
jest.mock(configPath, () => function () { return { lintOnSave: true } }, { virtual: true })
const service = createService()
expect(service.projectOptions.lintOnSave).toBe(true)
})