diff --git a/build/type-safe.json b/build/type-safe.json index 98661c4f65..289377133e 100644 --- a/build/type-safe.json +++ b/build/type-safe.json @@ -7,6 +7,8 @@ "packages/components/backtop/", "packages/components/badge/", "packages/components/base/", + "packages/components/breadcrumb/", + "packages/components/breadcrumb-item/", "packages/components/button/", "packages/components/button-group/", "packages/components/card/", diff --git a/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts b/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts deleted file mode 100644 index 44b2c92b31..0000000000 --- a/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { mount } from '@vue/test-utils' -import { Check } from '@element-plus/icons-vue' -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(` - - A - - `) - expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('?') - }) - - test('separatorIcon', () => { - const wrapper = _mount( - ` - - A - - ` - ) - expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') - expect(wrapper.findComponent(Check).exists()).toBe(true) - }) - - test('to', () => { - const wrapper = _mount(` - - A - - `) - expect(wrapper.find('.el-breadcrumb__inner').classes()).toContain('is-link') - }) - - test('single', () => { - const wrapper = _mount('A') - expect(wrapper.find('.el-breadcrumb__inner').text()).toBe('A') - expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') - }) -}) diff --git a/packages/components/breadcrumb/__tests__/breadcrumb.spec.tsx b/packages/components/breadcrumb/__tests__/breadcrumb.spec.tsx new file mode 100644 index 0000000000..a8444ed725 --- /dev/null +++ b/packages/components/breadcrumb/__tests__/breadcrumb.spec.tsx @@ -0,0 +1,50 @@ +import { mount } from '@vue/test-utils' +import { Check } from '@element-plus/icons-vue' +import Breadcrumb from '../src/breadcrumb.vue' +import BreadcrumbItem from '../src/breadcrumb-item.vue' +import type { VNode } from 'vue' + +const _mount = (render: () => VNode) => + mount(render, { + global: { + provide: { + breadcrumb: {}, + }, + }, + }) + +describe('Breadcrumb.vue', () => { + test('separator', () => { + const wrapper = _mount(() => ( + + A + + )) + expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('?') + }) + + test('separatorIcon', () => { + const wrapper = _mount(() => ( + + A + + )) + expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') + expect(wrapper.findComponent(Check).exists()).toBe(true) + }) + + test('to', () => { + const wrapper = _mount(() => ( + + A + + )) + expect(wrapper.find('.el-breadcrumb__inner').classes()).toContain('is-link') + }) + + test('single', () => { + const wrapper = _mount(() => A) + expect(wrapper.find('.el-breadcrumb__inner').text()).toBe('A') + expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') + }) +}) diff --git a/packages/components/breadcrumb/src/breadcrumb-item.vue b/packages/components/breadcrumb/src/breadcrumb-item.vue index a8975730af..0ee6273f1d 100644 --- a/packages/components/breadcrumb/src/breadcrumb-item.vue +++ b/packages/components/breadcrumb/src/breadcrumb-item.vue @@ -12,54 +12,35 @@ - diff --git a/packages/components/breadcrumb/src/breadcrumb.vue b/packages/components/breadcrumb/src/breadcrumb.vue index deba05d10b..4c78ba7ff3 100644 --- a/packages/components/breadcrumb/src/breadcrumb.vue +++ b/packages/components/breadcrumb/src/breadcrumb.vue @@ -9,34 +9,28 @@ - diff --git a/packages/tokens/breadcrumb.ts b/packages/tokens/breadcrumb.ts index 57b221f031..34cef772a3 100644 --- a/packages/tokens/breadcrumb.ts +++ b/packages/tokens/breadcrumb.ts @@ -1,5 +1,5 @@ import type { InjectionKey } from 'vue' import type { BreadcrumbProps } from '@element-plus/components/breadcrumb' -export const elBreadcrumbKey: InjectionKey = - Symbol('elBreadcrumbKey') +export const breadcrumbKey: InjectionKey = + Symbol('breadcrumbKey')