From 07c9ce7db76c501fe689ab93c31017cb137f1c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8F=8E=EF=B8=8F=20Yumo?= Date: Tue, 26 Nov 2024 15:07:35 +0800 Subject: [PATCH] test: fix mock current timestamp to prevent snapshot updates --- .../__snapshots__/demo-extend.test.ts.snap | 36 +++++++++---------- .../__tests__/__snapshots__/demo.test.ts.snap | 12 +++---- components/conversations/demo/group-sort.tsx | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/components/conversations/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/conversations/__tests__/__snapshots__/demo-extend.test.ts.snap index 82f3ffe3..6da64a17 100644 --- a/components/conversations/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/conversations/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -467,10 +467,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:00 + Conversation1 - 00:00:00 @@ -496,10 +496,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:03 + Conversation2 - 00:00:03 @@ -525,10 +525,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:07 + Conversation3 - 00:00:07 @@ -554,10 +554,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:10 + Conversation4 - 00:00:10 @@ -640,10 +640,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:14 + Conversation5 - 23:58:48 @@ -669,10 +669,10 @@ exports[`renders components/conversations/demo/group-sort.tsx extend context cor class="ant-conversations-item" > - Conversation - 08:00:18 + Conversation6 - 23:58:51 diff --git a/components/conversations/__tests__/__snapshots__/demo.test.ts.snap b/components/conversations/__tests__/__snapshots__/demo.test.ts.snap index e2cd2423..244266c6 100644 --- a/components/conversations/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/conversations/__tests__/__snapshots__/demo.test.ts.snap @@ -243,7 +243,7 @@ exports[`renders components/conversations/demo/group-sort.tsx correctly 1`] = ` - Conversation - 08:00:00 + Conversation1 - 00:00:00
  • - Conversation - 08:00:03 + Conversation2 - 00:00:03
  • - Conversation - 08:00:07 + Conversation3 - 00:00:07
  • - Conversation - 08:00:10 + Conversation4 - 00:00:10
  • @@ -336,7 +336,7 @@ exports[`renders components/conversations/demo/group-sort.tsx correctly 1`] = ` - Conversation - 08:00:14 + Conversation5 - 23:58:48
  • - Conversation - 08:00:18 + Conversation6 - 23:58:51
  • diff --git a/components/conversations/demo/group-sort.tsx b/components/conversations/demo/group-sort.tsx index 5906fa86..6fc1a73c 100644 --- a/components/conversations/demo/group-sort.tsx +++ b/components/conversations/demo/group-sort.tsx @@ -5,11 +5,11 @@ import { type GetProp, Space, theme } from 'antd'; import React from 'react'; const items: GetProp = Array.from({ length: 6 }).map((_, index) => { - const timestamp = index <= 3 ? Date.now() : Date.now() - 1000 * 60 * 60 * 24 * 2; + const timestamp = index <= 3 ? 1732204800000 : 1732204800000 - 60 * 60 * 24; return { key: `item${index + 1}`, - label: `Conversation - ${new Date(timestamp + index * 60 * 60).toLocaleTimeString()}`, + label: `Conversation${index + 1} - ${new Date(timestamp + index * 60 * 60).toLocaleTimeString()}`, timestamp: timestamp + index * 60, group: index <= 3 ? 'Today' : 'Yesterday', };