element-plus/packages/components/page-header/__tests__/page-header.spec.ts
三咲智子 55348b30b6
style: use prettier (#3228)
* style: use prettier

* style: just prettier format, no code changes

* style: eslint fix
object-shorthand, prefer-const

* style: fix no-void

* style: no-console
2021-09-04 19:29:28 +08:00

59 lines
1.5 KiB
TypeScript

import { mount } from '@vue/test-utils'
import PageHeader from '../src/index.vue'
const AXIOM = 'Rem is the best girl'
describe('PageHeader.vue', () => {
test('render test', () => {
const wrapper = mount(PageHeader, {
props: { content: AXIOM },
})
expect(wrapper.find('.el-page-header__content').text()).toEqual(AXIOM)
})
test('should render icon props', () => {
const icon = 'el-icon-arrow-left'
const wrapper = mount(PageHeader, {
props: { icon },
})
expect(wrapper.find('.el-page-header__icon i').classes()).toContain(icon)
})
test('should render icon slots', () => {
const wrapper = mount(PageHeader, {
slots: { icon: AXIOM },
})
expect(wrapper.find('.el-page-header__icon').text()).toEqual(AXIOM)
})
test('slot content', () => {
const wrapper = mount(PageHeader, {
slots: { content: AXIOM },
})
expect(wrapper.find('.el-page-header__content').text()).toEqual(AXIOM)
})
test('prop title', () => {
const wrapper = mount(PageHeader, {
props: { title: AXIOM },
})
expect(wrapper.find('.el-page-header__title').text()).toEqual(AXIOM)
})
test('slot prop', () => {
const wrapper = mount(PageHeader, {
slots: { title: AXIOM },
})
expect(wrapper.find('.el-page-header__title').text()).toEqual(AXIOM)
})
test('event back', async () => {
const wrapper = mount(PageHeader, {
props: { content: AXIOM },
})
await wrapper.find('.el-icon-back').trigger('click')
expect(wrapper.emitted('back')).toBeDefined()
})
})