wot-design-uni/tests/components/wd-navbar-capsule.test.ts
不如摸鱼去 7e84c5c91f
feat: 引入vitest做组件测试
* chore: 🚀 引入vitest做组件测试

* chore: 🚀 引入vitest做组件测试

* chore: 🚀 update workflow

* chore: 🚀 update workflow

* chore: 🚀 update workflow

* chore: 🚀 update workflow

* chore: 🚀 update nodejs version

* chore: 🚀 update nodejs version
2025-05-06 13:38:08 +08:00

46 lines
1.2 KiB
TypeScript

import { mount } from '@vue/test-utils'
import WdNavbarCapsule from '@/uni_modules/wot-design-uni/components/wd-navbar-capsule/wd-navbar-capsule.vue'
import { describe, test, expect, vi } from 'vitest'
describe('WdNavbarCapsule', () => {
// 测试基本渲染
test('基本渲染', () => {
const wrapper = mount(WdNavbarCapsule)
expect(wrapper.classes()).toContain('wd-navbar-capsule')
// 检查组件是否正确渲染
expect(wrapper.html()).toContain('wd-navbar-capsule')
})
// 测试组件结构
test('组件结构', () => {
const wrapper = mount(WdNavbarCapsule)
// 检查组件结构
expect(wrapper.html()).toContain('wd-navbar-capsule')
})
// 测试自定义类名
test('自定义类名', () => {
const customClass = 'my-capsule'
const wrapper = mount(WdNavbarCapsule, {
props: {
customClass
}
})
expect(wrapper.classes()).toContain(customClass)
})
// 测试自定义样式
test('自定义样式', () => {
const customStyle = 'background-color: red;'
const wrapper = mount(WdNavbarCapsule, {
props: {
customStyle
}
})
expect(wrapper.attributes('style')).toBe(customStyle)
})
})