chore: 清理旧测试基础设施并添加新测试框架
- 清理废弃的 CI/CD 工作流文件与 dogfood 输出 - 添加 vitest 测试环境配置(mocks、setup 文件) - 添加算法、服务、页面、工具类的单元测试 - 更新 vitest 配置、依赖与文档
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import ZiweiPage from '../index.vue'
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
ziwei: {
|
||||
generateChart: '排盘',
|
||||
birthTime: '出生时间',
|
||||
gender: '性别',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
function mountPage() {
|
||||
return mount(ZiweiPage, {
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: {
|
||||
picker: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
describe('ZiweiPage', () => {
|
||||
it('应包含出生信息输入表单', () => {
|
||||
const wrapper = mountPage()
|
||||
expect(wrapper.find('[data-test="birth-form"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('应包含排盘按钮', () => {
|
||||
const wrapper = mountPage()
|
||||
expect(wrapper.find('[data-test="generate-btn"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('点击排盘按钮应触发计算', async () => {
|
||||
const wrapper = mountPage()
|
||||
await wrapper.find('[data-test="generate-btn"]').trigger('click')
|
||||
expect(wrapper.vm.isCalculating).toBeDefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user