From 24c83de56d4882cde44aee05d8a13e598b789cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Wed, 10 Jun 2026 21:16:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Timestamp):=20=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=E9=A1=B5=E9=9D=A2=E7=BB=84=E4=BB=B6=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将子组件移至 components/ 子目录(LiveClock、ResultView) - 创建 __tests__/ 目录结构 - 更新所有相关导入路径 Co-authored-by: Cursor --- src/pages/Timestamp/__tests__/index.test.tsx | 11 +++++++++++ src/pages/Timestamp/{ => components}/LiveClock.tsx | 4 ++-- src/pages/Timestamp/{ => components}/ResultView.tsx | 0 src/pages/Timestamp/index.tsx | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 src/pages/Timestamp/__tests__/index.test.tsx rename src/pages/Timestamp/{ => components}/LiveClock.tsx (95%) rename src/pages/Timestamp/{ => components}/ResultView.tsx (100%) diff --git a/src/pages/Timestamp/__tests__/index.test.tsx b/src/pages/Timestamp/__tests__/index.test.tsx new file mode 100644 index 0000000..c46df35 --- /dev/null +++ b/src/pages/Timestamp/__tests__/index.test.tsx @@ -0,0 +1,11 @@ +import { render, screen } from '@testing-library/react'; +import { describe, it, expect } from 'vitest'; +import Index from '../index'; + +describe('Timestamp 页面', () => { + it('应该渲染页面标题', () => { + render(); + // 基本渲染测试 + expect(screen.getByRole('button')).toBeInTheDocument(); + }); +}); diff --git a/src/pages/Timestamp/LiveClock.tsx b/src/pages/Timestamp/components/LiveClock.tsx similarity index 95% rename from src/pages/Timestamp/LiveClock.tsx rename to src/pages/Timestamp/components/LiveClock.tsx index af10d18..1e1a625 100644 --- a/src/pages/Timestamp/LiveClock.tsx +++ b/src/pages/Timestamp/components/LiveClock.tsx @@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react'; import { Clock } from 'lucide-react'; import { toast } from 'sonner'; import { CopyButton } from '@/components/CopyButton'; -import type { UnitType } from './constants'; -import { msToUnit } from './constants'; +import type { UnitType } from '../constants'; +import { msToUnit } from '../constants'; import { useI18n } from '@/utils/chromeI18n'; import { cn } from '@/lib/utils'; diff --git a/src/pages/Timestamp/ResultView.tsx b/src/pages/Timestamp/components/ResultView.tsx similarity index 100% rename from src/pages/Timestamp/ResultView.tsx rename to src/pages/Timestamp/components/ResultView.tsx diff --git a/src/pages/Timestamp/index.tsx b/src/pages/Timestamp/index.tsx index 2120708..36ac8fd 100644 --- a/src/pages/Timestamp/index.tsx +++ b/src/pages/Timestamp/index.tsx @@ -1,8 +1,8 @@ import SwitchButtonGroup from '@/components/SwitchButtonGroup'; import { ZONES } from './constants'; import type { ModeType, UnitType, ZoneType } from './constants'; -import LiveClock from './LiveClock'; -import ResultView from './ResultView'; +import LiveClock from './components/LiveClock'; +import ResultView from './components/ResultView'; import { useTimestampConverter } from './useTimestampConverter'; import { useI18n } from '@/utils/chromeI18n'; import { cn } from '@/lib/utils';