feat: 添加测试框架和优化项目结构
- 添加 Jest 配置和测试设置 - 添加 use-categories hook 的单元测试 - 更新 CLAUDE.md 添加包管理工具说明 - 优化首页、视频页和频道页的组件结构 - 添加 .claude 命令配置文件 - 移除 bun.lock 和 package-lock.json,统一使用 bun - 更新 package.json 依赖 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
15
tests/example.test.ts
Normal file
15
tests/example.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
describe('示例测试', () => {
|
||||
it('应该能够运行基本的测试', () => {
|
||||
expect(1 + 1).toBe(2)
|
||||
})
|
||||
|
||||
it('应该能够测试对象', () => {
|
||||
const obj = { name: 'test', value: 123 }
|
||||
expect(obj).toEqual({ name: 'test', value: 123 })
|
||||
})
|
||||
|
||||
it('应该能够测试异步操作', async () => {
|
||||
const promise = Promise.resolve('success')
|
||||
await expect(promise).resolves.toBe('success')
|
||||
})
|
||||
})
|
||||
2
tests/mocks/fileMock.ts
Normal file
2
tests/mocks/fileMock.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
// Mock for static assets (images, fonts, etc.)
|
||||
module.exports = 'test-file-stub'
|
||||
14
tests/test-utils.tsx
Normal file
14
tests/test-utils.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react'
|
||||
import { render } from '@testing-library/react-native'
|
||||
import type { RenderOptions } from '@testing-library/react-native'
|
||||
|
||||
// 自定义渲染函数,可以在这里添加 Provider 等
|
||||
export function renderWithProviders(
|
||||
ui: React.ReactElement,
|
||||
options?: Omit<RenderOptions, 'wrapper'>,
|
||||
) {
|
||||
return render(ui, options)
|
||||
}
|
||||
|
||||
// 重新导出所有测试工具
|
||||
export * from '@testing-library/react-native'
|
||||
Reference in New Issue
Block a user