test(web): 添加 vitest 单元测试基础设施和初始测试用例
- 安装 vitest + @testing-library/react + @testing-library/jest-dom + jsdom - 创建 vitest.config.ts (jsdom 环境, 全局 API, e2e 目录排除) - 创建 test/setup.ts (@testing-library/jest-dom 匹配器) - 添加 29 个测试用例: health 常量 (14), useThemeMode hook (2), StatusTag 组件 (13)
This commit is contained in:
15
apps/web/src/hooks/useThemeMode.test.ts
Normal file
15
apps/web/src/hooks/useThemeMode.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { renderHook } from '@testing-library/react'
|
||||
import { useThemeMode } from './useThemeMode'
|
||||
|
||||
describe('useThemeMode', () => {
|
||||
it('should return false when no ConfigProvider is present (light default)', () => {
|
||||
const { result } = renderHook(() => useThemeMode())
|
||||
expect(result.current).toBe(false)
|
||||
})
|
||||
|
||||
it('should return a boolean value', () => {
|
||||
const { result } = renderHook(() => useThemeMode())
|
||||
expect(typeof result.current).toBe('boolean')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user