mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
55348b30b6
* style: use prettier * style: just prettier format, no code changes * style: eslint fix object-shorthand, prefer-const * style: fix no-void * style: no-console
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import Link from '../src/index.vue'
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
describe('Link.vue', () => {
|
|
test('render test', () => {
|
|
const wrapper = mount(Link, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
})
|
|
expect(wrapper.text()).toEqual(AXIOM)
|
|
})
|
|
|
|
test('it should handle click event when link is not disabled', async () => {
|
|
const wrapper = mount(Link, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
})
|
|
|
|
await wrapper.find('.el-link').trigger('click')
|
|
expect(wrapper.emitted('click')).toHaveLength(1)
|
|
})
|
|
|
|
test('it should disable click when link is disabled', async () => {
|
|
const wrapper = mount(Link, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
props: {
|
|
disabled: true,
|
|
},
|
|
})
|
|
|
|
await wrapper.find('.el-link').trigger('click')
|
|
expect(wrapper.emitted('click')).toBeUndefined()
|
|
})
|
|
|
|
test('icon slots', () => {
|
|
const linkName = 'test link'
|
|
const wrapper = mount(Link, {
|
|
slots: {
|
|
default: linkName,
|
|
icon: AXIOM,
|
|
},
|
|
})
|
|
expect(wrapper.text()).toContain(linkName)
|
|
expect(wrapper.text()).toContain(AXIOM)
|
|
})
|
|
})
|