element-plus/packages/components/link/__tests__/link.test.ts
三咲智子 1d13ebb05d
feat: drop jest (#7248)
* feat: drop jest

* test: remove ssr

* test: rename

* chore: update tsconfig
2022-04-19 16:51:44 +08:00

54 lines
1.2 KiB
TypeScript

import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import Link from '../src/link.vue'
const AXIOM = 'Rem is the best girl'
describe('Link.vue', () => {
it('render test', () => {
const wrapper = mount(Link, {
slots: {
default: AXIOM,
},
})
expect(wrapper.text()).toEqual(AXIOM)
})
it('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)
})
it('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()
})
it('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)
})
})