Explorar el Código

📝 docs(test): 将订单页面测试用例注释和描述翻译为中文

- 将测试文件中的英文注释替换为中文注释
- 将测试用例描述从英文转换为中文,提高代码可维护性
- 统一中文注释格式,保持代码风格一致性
yourname hace 3 meses
padre
commit
144900e679
Se han modificado 1 ficheros con 26 adiciones y 26 borrados
  1. 26 26
      mini/tests/pages/order-page.test.tsx

+ 26 - 26
mini/tests/pages/order-page.test.tsx

@@ -13,13 +13,13 @@ import taroMock, { mockUseRouter } 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 {
@@ -48,7 +48,7 @@ const Wrapper = ({ children }: { children: React.ReactNode }) => {
   )
 }
 
-// Mock API客户端
+// 模拟 API客户端
 jest.mock('@/api', () => ({
   orderClient: {
     $post: jest.fn()
@@ -138,7 +138,7 @@ describe('OrderPage', () => {
     taroMock.getEnv.mockReturnValue('WEB')
   })
 
-  it('should render order page correctly', () => {
+  it('应该正确渲染订单页面', () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -151,7 +151,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('price-per-unit')).toHaveTextContent('¥100/车')
   })
 
-  it('should show loading state', () => {
+  it('应该显示加载状态', () => {
     mockUseQuery.mockImplementation((options) => {
       if (options.queryKey?.[0] === 'route') {
         return { data: null, isLoading: true }
@@ -168,7 +168,7 @@ describe('OrderPage', () => {
     expect(screen.getByText('加载中...')).toBeInTheDocument()
   })
 
-  it('should handle phone number acquisition', async () => {
+  it('应该处理手机号获取', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -182,7 +182,7 @@ describe('OrderPage', () => {
     // 由于Taro API的限制,实际测试可能需要更复杂的模拟
   })
 
-  it('should handle passenger selection', async () => {
+  it('应该处理乘客选择', async () => {
     // 模拟已获取手机号的状态
     // 由于组件内部状态难以直接模拟,我们测试乘客选择器的基本功能
     render(
@@ -212,7 +212,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should validate payment prerequisites', async () => {
+  it('应该验证支付前提条件', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -235,7 +235,7 @@ describe('OrderPage', () => {
     // 这里需要模拟已获取手机号但未添加乘客的情况
   })
 
-  it('should handle successful payment flow', async () => {
+  it('应该处理成功的支付流程', async () => {
     // Mock成功的订单创建
     const mockOrderResponse = { id: 123 }
     const mockPaymentResponse = {
@@ -285,7 +285,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should handle payment failure', async () => {
+  it('应该处理支付失败', async () => {
     // Mock失败的订单创建
     mockUseMutation.mockImplementation(() => ({
       mutateAsync: async () => {
@@ -313,7 +313,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should handle user cancellation', async () => {
+  it('应该处理用户取消', async () => {
     // Mock用户取消支付
     taroMock.requestPayment.mockRejectedValue({
       errMsg: 'requestPayment:fail cancel'
@@ -338,7 +338,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should calculate total price correctly', () => {
+  it('应该正确计算总价', () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -350,7 +350,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('total-price')).toHaveTextContent('¥100')
   })
 
-  it('should validate seat availability', async () => {
+  it('应该验证座位可用性', async () => {
     // 测试拼车模式的座位验证
     mockUseRouter.mockReturnValue({
       params: {
@@ -394,7 +394,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('service-type')).toHaveTextContent('班次信息')
   })
 
-  it('should handle successful phone number acquisition', async () => {
+  it('应该处理成功的手机号获取', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -409,7 +409,7 @@ describe('OrderPage', () => {
     expect(getPhoneButton).toHaveAttribute('openType', 'getPhoneNumber')
   })
 
-  it('should handle phone number acquisition failure', async () => {
+  it('应该处理手机号获取失败', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -421,7 +421,7 @@ describe('OrderPage', () => {
     expect(getPhoneButton).toBeInTheDocument()
   })
 
-  it('should handle passenger deletion', async () => {
+  it('应该处理乘客删除', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -434,7 +434,7 @@ describe('OrderPage', () => {
     expect(addPassengerButton).toBeInTheDocument()
   })
 
-  it('should handle route data loading error', async () => {
+  it('应该处理路线数据加载错误', async () => {
     // 模拟路线数据加载失败
     mockUseQuery.mockImplementation((options) => {
       if (options.queryKey?.[0] === 'route') {
@@ -458,7 +458,7 @@ describe('OrderPage', () => {
     expect(screen.getByText('加载中...')).toBeInTheDocument()
   })
 
-  it('should handle passenger data loading error', async () => {
+  it('应该处理乘客数据加载错误', async () => {
     // 模拟乘客数据加载失败
     mockUseQuery.mockImplementation((options) => {
       if (options.queryKey?.[0] === 'route') {
@@ -488,7 +488,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('add-passenger-button')).toBeInTheDocument()
   })
 
-  it('should handle order creation failure', async () => {
+  it('应该处理订单创建失败', async () => {
     // Mock失败的订单创建
     mockUseMutation.mockImplementation(() => ({
       mutateAsync: async () => {
@@ -516,7 +516,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should handle payment creation failure', async () => {
+  it('应该处理支付创建失败', async () => {
     // Mock成功的订单创建但失败的支付创建
     mockUseMutation.mockImplementation((options) => {
       if (options.mutationKey?.[0] === 'createOrder') {
@@ -558,7 +558,7 @@ describe('OrderPage', () => {
     })
   })
 
-  it('should handle carpool mode correctly', async () => {
+  it('应该正确处理拼车模式', async () => {
     // 测试拼车模式
     mockUseRouter.mockReturnValue({
       params: {
@@ -594,7 +594,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('price-per-unit')).toHaveTextContent('¥100/人')
   })
 
-  it('should handle business charter mode correctly', async () => {
+  it('应该正确处理商务包车模式', async () => {
     // 测试商务包车模式
     mockUseRouter.mockReturnValue({
       params: {
@@ -615,7 +615,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('price-per-unit')).toHaveTextContent('¥100/车')
   })
 
-  it('should handle empty activity name', async () => {
+  it('应该处理空活动名称', async () => {
     // 测试空活动名称的情况
     mockUseRouter.mockReturnValue({
       params: {
@@ -635,7 +635,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('activity-name')).toHaveTextContent('活动')
   })
 
-  it('should handle URL encoded activity name', async () => {
+  it('应该处理URL编码的活动名称', async () => {
     // 测试URL编码的活动名称
     const encodedActivityName = encodeURIComponent('测试活动名称')
     mockUseRouter.mockReturnValue({
@@ -656,7 +656,7 @@ describe('OrderPage', () => {
     expect(screen.getByTestId('activity-name')).toHaveTextContent('测试活动名称')
   })
 
-  it('should display departure time as customer service confirmation message', async () => {
+  it('应该将出发时间显示为客服确认信息', async () => {
     render(
       <Wrapper>
         <OrderPage />
@@ -675,7 +675,7 @@ describe('OrderPage', () => {
     expect(screen.getAllByText('包车价格').length).toBeGreaterThan(0)
   })
 
-  it('should apply time display optimization for both carpool and charter services', async () => {
+  it('应该对拼车和包车服务都应用时间显示优化', async () => {
     // 测试拼车模式
     mockUseRouter.mockReturnValue({
       params: {