element-plus/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts
Aex 4510816802
refactor(componentes): deprecate the icon font of some components (#4067)
* refactor(components): [el-breadcumb] icon

* refactor(components): el-tabs icon

* refactor(components): color picker icon

* refactor(components): menus icon

* refactor(components): loading spinner icon

* fix(components): panel-data-pick elicon import

* refactor(components): dropdown item icon

* refactor(components): tabs plus icon

* fix: message & tabs icon test

* fix(components): breadcrumb docs

* fix(components): colorPicker docs

* fix(components): loading docs

Co-authored-by: imswk <syfzxx@vip.qq.com>
2021-10-28 23:37:26 +08:00

66 lines
1.7 KiB
TypeScript

import { mount } from '@vue/test-utils'
import { Check } from '@element-plus/icons'
import Breadcrumb from '../src/breadcrumb.vue'
import BreadcrumbItem from '../src/breadcrumb-item.vue'
const _mount = (template: string) =>
mount(
{
components: {
'el-breadcrumb': Breadcrumb,
'el-breadcrumb-item': BreadcrumbItem,
},
data() {
return {
Check,
}
},
template,
},
{
global: {
provide: {
breadcrumb: {},
},
},
}
)
describe('Breadcrumb.vue', () => {
test('separator', () => {
const wrapper = _mount(`
<el-breadcrumb separator="?">
<el-breadcrumb-item>A</el-breadcrumb-item>
</el-breadcrumb>
`)
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('?')
})
test('separatorIcon', () => {
const wrapper = _mount(
`
<el-breadcrumb :separatorIcon="Check">
<el-breadcrumb-item>A</el-breadcrumb-item>
</el-breadcrumb>
`
)
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('')
expect(wrapper.findComponent(Check).exists()).toBe(true)
})
test('to', () => {
const wrapper = _mount(`
<el-breadcrumb separator="?" :separatorIcon="Check">
<el-breadcrumb-item to="/index">A</el-breadcrumb-item>
</el-breadcrumb>
`)
expect(wrapper.find('.el-breadcrumb__inner').classes()).toContain('is-link')
})
test('single', () => {
const wrapper = _mount('<el-breadcrumb-item>A</el-breadcrumb-item>')
expect(wrapper.find('.el-breadcrumb__inner').text()).toBe('A')
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('')
})
})