|
|
@@ -9,13 +9,13 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
import OrderDetailPage from '@/pages/order-detail/index'
|
|
|
|
|
|
// 导入 Taro mock 函数
|
|
|
-import taroMock, { mockUseRouter, mockGetCurrentInstance } from '../../tests/__mocks__/taroMock'
|
|
|
+import taroMock from '../../tests/__mocks__/taroMock'
|
|
|
|
|
|
-// Mock React Query
|
|
|
+// 模拟 React Query
|
|
|
const mockUseQuery = jest.fn()
|
|
|
const mockUseMutation = jest.fn()
|
|
|
|
|
|
-// Mock React Query
|
|
|
+// 模拟 React Query
|
|
|
jest.mock('@tanstack/react-query', () => {
|
|
|
const actual = jest.requireActual('@tanstack/react-query')
|
|
|
return {
|
|
|
@@ -122,7 +122,7 @@ describe('OrderDetailPage', () => {
|
|
|
taroMock.navigateBack.mockClear()
|
|
|
})
|
|
|
|
|
|
- it('should render order detail page correctly', () => {
|
|
|
+ it('应该正确渲染订单详情页面', () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|
|
|
@@ -135,7 +135,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('上车地点 → 下车地点')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should display departure time as customer service confirmation message', () => {
|
|
|
+ it('应该将出发时间显示为客服确认信息', () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|
|
|
@@ -156,7 +156,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('下单时间:')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should show loading state', () => {
|
|
|
+ it('应该显示加载状态', () => {
|
|
|
mockUseQuery.mockImplementation((options) => {
|
|
|
if (options.queryKey?.[0] === 'order') {
|
|
|
return { data: null, isLoading: true }
|
|
|
@@ -173,7 +173,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('加载中...')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it.skip('should handle order cancellation', async () => {
|
|
|
+ it.skip('应该处理订单取消', async () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|
|
|
@@ -200,7 +200,7 @@ describe('OrderDetailPage', () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- it('should display passenger information', () => {
|
|
|
+ it('应该显示乘客信息', () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|
|
|
@@ -215,7 +215,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('110101199001011235')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should display route snapshot information', () => {
|
|
|
+ it('应该显示路线快照信息', () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|
|
|
@@ -228,7 +228,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('¥100')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should handle error state', () => {
|
|
|
+ it('应该处理错误状态', () => {
|
|
|
mockUseQuery.mockImplementation((options) => {
|
|
|
if (options.queryKey?.[0] === 'order') {
|
|
|
return {
|
|
|
@@ -250,7 +250,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('返回')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should handle missing order id', () => {
|
|
|
+ it('应该处理缺失订单ID的情况', () => {
|
|
|
// Mock 没有订单ID的情况
|
|
|
taroMock.getCurrentInstance.mockReturnValue({
|
|
|
router: {
|
|
|
@@ -278,7 +278,7 @@ describe('OrderDetailPage', () => {
|
|
|
expect(screen.getByText('加载失败')).toBeInTheDocument()
|
|
|
})
|
|
|
|
|
|
- it('should apply time display optimization consistently', () => {
|
|
|
+ it('应该一致应用时间显示优化', () => {
|
|
|
render(
|
|
|
<Wrapper>
|
|
|
<OrderDetailPage />
|