element-plus/packages/button/__tests__/button.spec.ts

37 lines
685 B
TypeScript
Raw Normal View History

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-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: {
default: AXIOM
},
...COMMON_CONFIG,
})
expect(instance.text()).toEqual(AXIOM)
})
test('handle click', async () => {
const instance = mount(Button, {
slots: {
default: AXIOM
},
...COMMON_CONFIG,
})
await instance.trigger('click')
expect(instance.emitted()).toBeDefined()
2020-07-24 16:44:56 +08:00
})
})