mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
feat: add the first test case
This commit is contained in:
parent
b42f434c1e
commit
f0c59af2be
@ -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()
|
||||
|
||||
})
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ const ELEMENT: {
|
||||
} = {}
|
||||
// TODOS: replace these interface definition with actual ElForm interface
|
||||
interface ElForm {
|
||||
disabled: boolean;
|
||||
disabled: boolean;
|
||||
}
|
||||
interface ElFormItem {
|
||||
elFormItemSize: number;
|
||||
@ -89,4 +89,4 @@ export default {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
6
typings/vue-shim.d.ts
vendored
6
typings/vue-shim.d.ts
vendored
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user