Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(unit): add breadcrumb unit test #457

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 72 additions & 3 deletions packages/vue/src/breadcrumb/__tests__/breadcrumb.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mountPcMode } from '@opentiny-internal/vue-test-utils'
import { describe, test, expect } from 'vitest'
import Breadcrumb from '@opentiny/vue-breadcrumb'
import { IconBoat } from '@opentiny/vue-icon'

describe('PC Mode', () => {
const mount = mountPcMode
Expand Down Expand Up @@ -28,9 +29,77 @@ describe('PC Mode', () => {
expect(wrapper.find('.tiny-breadcrumb__item .tiny-breadcrumb__inner').text()).toBe('导航1')
})

test.todo('separator-icon, 设置图标类的分隔符')
test('separator-icon', () => {

test.todo('separator, 设置分隔符')

test.todo('text-field, 指定面包屑的显示字段,结合options使用,默认为label')
const options = [
{
label: '导航1',
to: { path: '/' }
},
{
label: '导航2',
to: { path: '/breadcrumb' }
},
{
label: '导航3',
replace: true
}
]
const wrapper = mount(
() => <Breadcrumb options={options} separatorIcon={IconBoat()}></Breadcrumb>,
)
expect(wrapper.find('.tiny-breadcrumb__separator-cls').exists()).toBeTruthy()
expect(wrapper.findAll('.tiny-breadcrumb__separator-cls')).toHaveLength(3)
})

test('separator', () => {

const options = [
{
label: '导航1',
to: { path: '/' }
},
{
label: '导航2',
to: { path: '/breadcrumb' }
},
{
label: '导航3',
replace: true
}
]
const wrapper = mount(
() => <Breadcrumb options={options} separator='/'></Breadcrumb>,
)

expect(wrapper.find('.tiny-breadcrumb__separator').exists()).toBeTruthy()
expect(wrapper.find('.tiny-breadcrumb__separator').text()).toBe('/')
})

test('text-field, 指定面包屑的显示字段,结合options使用,默认为label', () => {

const options = [
{
name: '导航1',
to: { path: '/' }
},
{
name: '导航2',
to: { path: '/breadcrumb' }
},
{
name: '导航3',
replace: true
}
]
const wrapper = mount(
() => <Breadcrumb options={options} separator='/' textField='name'></Breadcrumb>,
)

expect(wrapper.find('.tiny-breadcrumb').exists()).toBeTruthy()
expect(wrapper.find('.tiny-breadcrumb__item').exists()).toBeTruthy()
expect(wrapper.findAll('.tiny-breadcrumb__item')).toHaveLength(3)
expect(wrapper.find('.tiny-breadcrumb__item .tiny-breadcrumb__inner').text()).toBe('导航1')
})
})