From 17e51ad17177b2dff602cf497816276ba6b0c112 Mon Sep 17 00:00:00 2001 From: Hennessy Nguyen Date: Tue, 2 Jul 2024 12:48:54 +0700 Subject: [PATCH] Edit test in message preview timestamp --- src/tests/hooks/useMessagesContext.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tests/hooks/useMessagesContext.test.js b/src/tests/hooks/useMessagesContext.test.js index cc86c8a..00c5c6b 100644 --- a/src/tests/hooks/useMessagesContext.test.js +++ b/src/tests/hooks/useMessagesContext.test.js @@ -1,6 +1,7 @@ import { renderHook, act } from '@testing-library/react'; import { MessagesContextProvider } from '../../context/MessagesContext'; import { useMessagesContext} from '../../hooks/useMessagesContext'; +import { format } from 'date-fns'; const wrapper = ({ children }) => ( {children} @@ -52,8 +53,9 @@ describe('useMessagesContext', () => { act(() => { result.current.dispatch({ type: 'SET_PREVIEW_MESSAGE', payload: testMessage }); }) + const expectedDate = format(new Date(testMessage.timestamp), 'MM/dd') expect(result.current.previewMessages[testMessage.chatId]).toEqual(testMessage.message); - expect(result.current.previewMessagesTimestamp[testMessage.chatId]).toEqual('06/02'); + expect(result.current.previewMessagesTimestamp[testMessage.chatId]).toEqual(expectedDate); }); it('dispatches NEW_MESSAGE action correctly', () => {