2020-07-24 19:28:18 +08:00
|
|
|
import {mount} from '@vue/test-utils'
|
2020-07-24 17:26:08 +08:00
|
|
|
import Button from '../src/index.vue'
|
|
|
|
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
const COMMON_CONFIG = {
|
|
|
|
global: {
|
|
|
|
provide: {
|
|
|
|
elForm: {},
|
|
|
|
elFormItem: {},
|
2020-07-27 16:17:41 +08:00
|
|
|
},
|
|
|
|
},
|
2020-07-24 17:26:08 +08:00
|
|
|
}
|
|
|
|
|
2020-07-24 16:44:56 +08:00
|
|
|
describe('Button.vue', () => {
|
2020-07-24 17:26:08 +08:00
|
|
|
test('render text', () => {
|
|
|
|
const instance = mount(Button, {
|
|
|
|
slots: {
|
2020-07-27 16:17:41 +08:00
|
|
|
default: AXIOM,
|
2020-07-24 17:26:08 +08:00
|
|
|
},
|
|
|
|
...COMMON_CONFIG,
|
|
|
|
})
|
|
|
|
expect(instance.text()).toEqual(AXIOM)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('handle click', async () => {
|
|
|
|
const instance = mount(Button, {
|
|
|
|
slots: {
|
2020-07-27 16:17:41 +08:00
|
|
|
default: AXIOM,
|
2020-07-24 17:26:08 +08:00
|
|
|
},
|
|
|
|
...COMMON_CONFIG,
|
|
|
|
})
|
|
|
|
await instance.trigger('click')
|
|
|
|
expect(instance.emitted()).toBeDefined()
|
|
|
|
|
2020-07-24 16:44:56 +08:00
|
|
|
})
|
|
|
|
})
|