test(collapse): improve collapse test coverage #5971
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
#5631
💡 需求背景和解决方案
背景
为了提升 TDesign Vue Next 组件库的质量和稳定性,增强组件的可靠性,开展测试覆盖率提升专项。Collapse 组件作为重要的交互组件,需要全面的测试覆盖来确保在各种场景下表现稳定。
解决方案
主要改进
📋 详细变更内容
新增测试文件
collapse-panel.test.tsx
: CollapsePanel 子组件专项测试(31 个用例)collapse.utils.test.tsx
: 工具函数和内部逻辑测试(15 个用例)collapse.hooks.test.tsx
: 自定义 Hook 和响应式逻辑测试(13 个用例)fake-arrow.test.tsx
: 依赖组件 FakeArrow 测试(6 个用例)增强现有测试
collapse.test.tsx
: 主组件测试从 19 个增加到 31 个用例Bug 修复
packages/components/common-components/fake-arrow.tsx
中的类型定义错误:测试覆盖范围
📝 更新日志
tdesign-vue-next
☑️ 请求合并前的自查清单
🧪 测试结果
# 测试覆盖率结果 ✅ 96 个测试用例全部通过 ✅ 整体覆盖率:93.45% statements, 95.23% branches ✅ 核心组件覆盖率接近 100% ✅ 零测试失败,零 Vue 警告
📊 覆盖率对比