Files
prompt-optimizer/packages/ui/tests/unit/components.test.js
linshen 63ab9e66cd feat(test): 建立完整的测试基础设施和集成测试
- 建立 VCR 测试基础设施,支持 LLM API 回放
- 添加错误门禁和冒烟测试
- 添加 LLM 服务集成测试(P0)
- 记录测试进展并更新任务计划
2026-01-03 21:08:00 +08:00

47 lines
1.2 KiB
JavaScript

import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import { ActionButtonUI, ContentCardUI } from '../../src'
describe('基础UI组件测试', () => {
describe('ActionButtonUI', () => {
it('应该正确渲染按钮文本', () => {
const buttonText = '测试按钮'
const wrapper = mount(ActionButtonUI, {
props: {
text: buttonText,
icon: '??'
}
})
expect(wrapper.text()).toContain(buttonText)
})
it('应该正确处理loading状态', async () => {
const wrapper = mount(ActionButtonUI, {
props: {
text: '测试按钮',
icon: '??',
loading: false
}
})
expect(wrapper.props('loading')).toBe(false)
await wrapper.setProps({ loading: true })
expect(wrapper.props('loading')).toBe(true)
})
})
describe('ContentCardUI', () => {
it('应该正确渲染slot内容', () => {
const slotContent = '测试内容'
const wrapper = mount(ContentCardUI, {
slots: {
default: slotContent
}
})
expect(wrapper.text()).toContain(slotContent)
})
})
})