From 00988318d93ef7ab87f1724c385ed6d2e4b74128 Mon Sep 17 00:00:00 2001 From: ss0526100 Date: Tue, 20 Aug 2024 11:14:48 +0900 Subject: [PATCH] =?UTF-8?q?test:=EB=A7=88=EC=A7=80=EB=A7=89=20=EB=8B=A4?= =?UTF-8?q?=EB=9D=BD=EB=B0=A9=20Id=EB=A5=BC=20=EC=9D=B4=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/queries/useChats.test.tsx | 4 ++++ frontend/src/mocks/handler/chatHandler.ts | 22 +++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/hooks/queries/useChats.test.tsx b/frontend/src/hooks/queries/useChats.test.tsx index 01a344c7d..bfdc3dd12 100644 --- a/frontend/src/hooks/queries/useChats.test.tsx +++ b/frontend/src/hooks/queries/useChats.test.tsx @@ -8,6 +8,7 @@ import { } from '../../mocks/handler/chatHandler'; import { renderHook } from '@testing-library/react'; +import { setLastDarakbangId } from '@_common/lastDarakbangManager'; import useChats from './useChats'; const queryClient = new QueryClient(); @@ -16,6 +17,9 @@ const wrapper = ({ children }: { children: ReactNode }) => ( ); describe('useChats', () => { + beforeEach(() => { + setLastDarakbangId(1); + }); afterEach(() => { nowChatServerData.length = 0; initChatIndex(); diff --git a/frontend/src/mocks/handler/chatHandler.ts b/frontend/src/mocks/handler/chatHandler.ts index 9e30c2e5a..8b56a9ed7 100644 --- a/frontend/src/mocks/handler/chatHandler.ts +++ b/frontend/src/mocks/handler/chatHandler.ts @@ -2,7 +2,6 @@ import { HttpResponse, http } from 'msw'; import { Chat } from '@_types/index'; import mockedChats from './mockedChats'; -import ENDPOINTS from '@_apis/endPoints'; let nowChatIndex = 0; @@ -26,13 +25,16 @@ export const chatSliceIndexes = [ ]; export const chatHandler = [ - http.get(ENDPOINTS.chat, async ({ request }) => { - const url = new URL(request.url); - - const recentChatId = +(url.searchParams.get('recentChatId') || 0); - - return HttpResponse.json({ - data: { chats: nowChatServerData.slice(recentChatId) }, - }); - }), + http.get( + `${process.env.BASE_URL}/v1/darakbang/1/chat`, + async ({ request }) => { + const url = new URL(request.url); + + const recentChatId = +(url.searchParams.get('recentChatId') || 0); + + return HttpResponse.json({ + data: { chats: nowChatServerData.slice(recentChatId) }, + }); + }, + ), ];