diff --git a/src/app/mocks/dir/response.ts b/src/app/mocks/dir/response.ts index a9cc3d4..5498416 100644 --- a/src/app/mocks/dir/response.ts +++ b/src/app/mocks/dir/response.ts @@ -1,8 +1,10 @@ -import { HttpResponse } from 'msw'; +import { HttpResponse, delay } from 'msw'; import { errorMessage } from '../consts/error'; -export function createHttpSuccessResponse(data: T) { +export async function createHttpSuccessResponse(data: T) { + await delay(); + return HttpResponse.json( { code: '2000', @@ -12,7 +14,9 @@ export function createHttpSuccessResponse(data: T) { ); } -export function createHttpErrorResponse(code: keyof typeof errorMessage) { +export async function createHttpErrorResponse(code: keyof typeof errorMessage) { + await delay(); + return HttpResponse.json( { code, diff --git a/src/app/mocks/handler/feed.ts b/src/app/mocks/handler/feed.ts index 5db5477..75847a6 100644 --- a/src/app/mocks/handler/feed.ts +++ b/src/app/mocks/handler/feed.ts @@ -1,4 +1,4 @@ -import { delay, http } from 'msw'; +import { http } from 'msw'; import { feeds } from '../consts/feed'; import { reports } from '../consts/report'; @@ -28,7 +28,7 @@ export const feedHandlers = [ /** * @todo pageCount를 쿼리 파라미터로 받도록 수정 */ - http.get('/feeds', async ({ request }) => { + http.get('/feeds', ({ request }) => { const url = new URL(request.url); const page = url.searchParams.get('page') || 1; const count = url.searchParams.get('count') || 10; @@ -48,8 +48,6 @@ export const feedHandlers = [ const endOfPageRange = formattedPage * pageCount; const hasNextPage = endOfPageRange < totalFeeds; - await delay(Math.floor(Math.random() * 4000)); - return createHttpSuccessResponse({ feeds: feedsData, currentPageNumber: pageCount,