|
@@ -3,6 +3,7 @@
|
|
|
## 版本信息
|
|
## 版本信息
|
|
|
| 版本 | 日期 | 描述 | 作者 |
|
|
| 版本 | 日期 | 描述 | 作者 |
|
|
|
|------|------|------|------|
|
|
|------|------|------|------|
|
|
|
|
|
+| 2.1 | 2025-10-15 | 修正Taro测试位置,统一使用mini/tests/目录 | Winston |
|
|
|
| 2.0 | 2025-10-15 | 整合精确样式迁移内容,优化文档结构 | Winston |
|
|
| 2.0 | 2025-10-15 | 整合精确样式迁移内容,优化文档结构 | Winston |
|
|
|
| 1.0 | 2025-10-15 | 初始mini-demo迁移指导规范 | Winston |
|
|
| 1.0 | 2025-10-15 | 初始mini-demo迁移指导规范 | Winston |
|
|
|
|
|
|
|
@@ -482,18 +483,24 @@ export default function HomePage() {
|
|
|
|
|
|
|
|
**新测试结构:**
|
|
**新测试结构:**
|
|
|
```typescript
|
|
```typescript
|
|
|
-// tests/unit/mini/pages/home/index.test.tsx
|
|
|
|
|
-import { render } from '@testing-library/react'
|
|
|
|
|
|
|
+// mini/tests/pages/home/index.test.tsx
|
|
|
|
|
+import TestUtils from '@tarojs/test-utils-react'
|
|
|
import HomePage from '@/pages/home/index'
|
|
import HomePage from '@/pages/home/index'
|
|
|
|
|
|
|
|
|
|
+const testUtils = new TestUtils()
|
|
|
|
|
+
|
|
|
describe('HomePage', () => {
|
|
describe('HomePage', () => {
|
|
|
- it('renders travel type selector', () => {
|
|
|
|
|
- const { getByText } = render(<HomePage />)
|
|
|
|
|
- expect(getByText('大巴拼车')).toBeInTheDocument()
|
|
|
|
|
|
|
+ it('renders travel type selector', async () => {
|
|
|
|
|
+ await testUtils.mount(HomePage)
|
|
|
|
|
+ const travelTypeSelector = await testUtils.queries.waitForQuerySelector('.travel-type-selector')
|
|
|
|
|
+ expect(travelTypeSelector).toBeInTheDocument()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('handles location selection', () => {
|
|
|
|
|
|
|
+ it('handles location selection', async () => {
|
|
|
// 测试地点选择功能
|
|
// 测试地点选择功能
|
|
|
|
|
+ await testUtils.mount(HomePage)
|
|
|
|
|
+ const locationPicker = await testUtils.queries.waitForQuerySelector('.location-picker')
|
|
|
|
|
+ expect(locationPicker).toBeInTheDocument()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
```
|
|
```
|