mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-21 03:48:36 -05:00
b62c6ba7f2
close #2262
89 lines
2.2 KiB
JavaScript
89 lines
2.2 KiB
JavaScript
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin')
|
|
|
|
test('base', async () => {
|
|
const { pkg, files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-mocha',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
// mock presence of the eslint plugin
|
|
{
|
|
id: 'eslint',
|
|
apply: () => {},
|
|
options: {}
|
|
}
|
|
])
|
|
|
|
expect(pkg.scripts['test:unit']).toBe('vue-cli-service test:unit')
|
|
expect(pkg.devDependencies).toHaveProperty('@vue/test-utils')
|
|
expect(files['tests/unit/.eslintrc.js']).toMatch('mocha: true')
|
|
|
|
const spec = files['tests/unit/example.spec.js']
|
|
expect(spec).toMatch(`import { expect } from 'chai'`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).to.include(msg)`)
|
|
})
|
|
|
|
test('with TS', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-mocha',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
// mock presence of the ts plugin
|
|
{
|
|
id: 'typescript',
|
|
apply: () => {},
|
|
options: {}
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.ts']
|
|
expect(spec).toMatch(`import { expect } from 'chai'`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).to.include(msg)`)
|
|
})
|
|
|
|
test('bare', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-mocha',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
{
|
|
id: '@vue/cli-service',
|
|
apply: () => {},
|
|
options: { bare: true }
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.js']
|
|
expect(spec).toMatch(`const wrapper = shallowMount(App)`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).to.include(\`Welcome to Your Vue.js App\`)`)
|
|
})
|
|
|
|
test('TS + bare', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-mocha',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
{
|
|
id: 'typescript',
|
|
apply: () => {},
|
|
options: {}
|
|
},
|
|
{
|
|
id: '@vue/cli-service',
|
|
apply: () => {},
|
|
options: { bare: true }
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.ts']
|
|
expect(spec).toMatch(`const wrapper = shallowMount(App)`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).to.include(\`Welcome to Your Vue.js + TypeScript App\`)`)
|
|
})
|