2020-08-01 22:03:08 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import Breadcrumb from '../src/index.vue'
|
|
|
|
import BreadcrumbItem from '../src/item.vue'
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
const _mount = (template: string) =>
|
|
|
|
mount(
|
|
|
|
{
|
|
|
|
components: {
|
|
|
|
'el-breadcrumb': Breadcrumb,
|
|
|
|
'el-breadcrumb-item': BreadcrumbItem,
|
|
|
|
},
|
|
|
|
template,
|
2020-08-04 16:08:14 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
{
|
|
|
|
global: {
|
|
|
|
provide: {
|
|
|
|
breadcrumb: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
2020-08-01 22:03:08 +08:00
|
|
|
|
|
|
|
describe('Breadcrumb.vue', () => {
|
|
|
|
test('separator', () => {
|
2020-08-03 14:36:19 +08:00
|
|
|
const wrapper = _mount(`
|
|
|
|
<el-breadcrumb separator="?">
|
|
|
|
<el-breadcrumb-item>A</el-breadcrumb-item>
|
|
|
|
</el-breadcrumb>
|
|
|
|
`)
|
2020-08-01 22:03:08 +08:00
|
|
|
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('?')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('separatorClass', () => {
|
2020-08-03 14:36:19 +08:00
|
|
|
const wrapper = _mount(`
|
|
|
|
<el-breadcrumb separator="?" separatorClass="test">
|
|
|
|
<el-breadcrumb-item>A</el-breadcrumb-item>
|
|
|
|
</el-breadcrumb>
|
|
|
|
`)
|
2020-08-01 22:03:08 +08:00
|
|
|
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('')
|
2021-09-04 19:29:28 +08:00
|
|
|
expect(wrapper.find('.el-breadcrumb__separator').classes()).toContain(
|
|
|
|
'test'
|
|
|
|
)
|
2020-08-01 22:03:08 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test('to', () => {
|
2020-08-03 14:36:19 +08:00
|
|
|
const wrapper = _mount(`
|
|
|
|
<el-breadcrumb separator="?" separatorClass="test">
|
|
|
|
<el-breadcrumb-item to="/index">A</el-breadcrumb-item>
|
|
|
|
</el-breadcrumb>
|
|
|
|
`)
|
2020-08-01 22:03:08 +08:00
|
|
|
expect(wrapper.find('.el-breadcrumb__inner').classes()).toContain('is-link')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('single', () => {
|
2020-08-03 14:36:19 +08:00
|
|
|
const wrapper = _mount('<el-breadcrumb-item>A</el-breadcrumb-item>')
|
2020-08-01 22:03:08 +08:00
|
|
|
expect(wrapper.find('.el-breadcrumb__inner').text()).toBe('A')
|
|
|
|
expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('')
|
|
|
|
})
|
|
|
|
})
|