feat: add the first test case

This commit is contained in:
Herrington Darkholme 2020-07-24 17:26:08 +08:00
parent b42f434c1e
commit f0c59af2be
3 changed files with 39 additions and 7 deletions

View File

@ -1,6 +1,36 @@
import {mount, config} from '@vue/test-utils'
import Button from '../src/index.vue'
const AXIOM = 'Rem is the best girl'
const COMMON_CONFIG = {
global: {
provide: {
elForm: {},
elFormItem: {},
}
}
}
describe('Button.vue', () => {
test('hello world', () => {
const bestGirl = 'Rem'
expect(bestGirl).not.toMatch('Emilia')
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()
})
})

View File

@ -1,5 +1,7 @@
declare module '*.vue' {
import { Component } from 'vue'
const _default: Component
import { Component, ComponentPublicInstance } from 'vue'
const _default: Component & {
new (): ComponentPublicInstance
}
export default _default
}