chore: 清理旧测试基础设施并添加新测试框架
- 清理废弃的 CI/CD 工作流文件与 dogfood 输出 - 添加 vitest 测试环境配置(mocks、setup 文件) - 添加算法、服务、页面、工具类的单元测试 - 更新 vitest 配置、依赖与文档
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { vi } from 'vitest'
|
||||
|
||||
const uni = {
|
||||
getStorageSync: vi.fn((key: string) => {
|
||||
const store: Record<string, string> = (globalThis as any).__uniStorage__ ?? {}
|
||||
return store[key] ?? ''
|
||||
}),
|
||||
setStorageSync: vi.fn((key: string, value: any) => {
|
||||
if (!(globalThis as any).__uniStorage__) (globalThis as any).__uniStorage__ = {}
|
||||
;(globalThis as any).__uniStorage__[key] = JSON.stringify(value)
|
||||
}),
|
||||
removeStorageSync: vi.fn((key: string) => {
|
||||
if ((globalThis as any).__uniStorage__) delete (globalThis as any).__uniStorage__[key]
|
||||
}),
|
||||
clearStorageSync: vi.fn(() => {
|
||||
;(globalThis as any).__uniStorage__ = {}
|
||||
}),
|
||||
showToast: vi.fn(),
|
||||
showLoading: vi.fn(),
|
||||
hideLoading: vi.fn(),
|
||||
showModal: vi.fn(),
|
||||
navigateTo: vi.fn(),
|
||||
navigateBack: vi.fn(),
|
||||
redirectTo: vi.fn(),
|
||||
switchTab: vi.fn(),
|
||||
reLaunch: vi.fn(),
|
||||
getSystemInfoSync: vi.fn(() => ({
|
||||
platform: 'devtools',
|
||||
screenWidth: 375,
|
||||
screenHeight: 812,
|
||||
})),
|
||||
}
|
||||
|
||||
vi.stubGlobal('uni', uni)
|
||||
|
||||
beforeEach(() => {
|
||||
;(globalThis as any).__uniStorage__ = {}
|
||||
})
|
||||
Reference in New Issue
Block a user