From a69d0832fb7142f74fe616ed3f08e9e6a9f2be3f Mon Sep 17 00:00:00 2001 From: BangDori Date: Fri, 10 May 2024 19:35:43 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20Http=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EB=B0=8F=20=EC=8B=A4=ED=8C=A8=20=EC=9D=91=EB=8B=B5=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=ED=95=A8=EC=88=98=20delay=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/dir/response.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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, From 6a18f2e37079af311792fbdc73019eec70f880e3 Mon Sep 17 00:00:00 2001 From: BangDori Date: Fri, 10 May 2024 19:38:40 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=ED=94=BC=EB=93=9C=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20delay=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/handler/feed.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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, From d145227621792d5b62d70f578206835f573856e8 Mon Sep 17 00:00:00 2001 From: BangDori Date: Fri, 10 May 2024 19:41:22 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EB=B3=80=EC=88=98=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/dir/response.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/mocks/dir/response.ts b/src/app/mocks/dir/response.ts index 5498416..d50cd38 100644 --- a/src/app/mocks/dir/response.ts +++ b/src/app/mocks/dir/response.ts @@ -2,8 +2,11 @@ import { HttpResponse, delay } from 'msw'; import { errorMessage } from '../consts/error'; +/** 0 <= 응답 시간 <= 4초 */ +const delayTime = Math.random() * 4001; + export async function createHttpSuccessResponse(data: T) { - await delay(); + await delay(delayTime); return HttpResponse.json( { @@ -15,7 +18,7 @@ export async function createHttpSuccessResponse(data: T) { } export async function createHttpErrorResponse(code: keyof typeof errorMessage) { - await delay(); + await delay(delayTime); return HttpResponse.json( { From 3d3577beb9e5c24874c6f827714965caea083276 Mon Sep 17 00:00:00 2001 From: BangDori Date: Fri, 10 May 2024 20:09:01 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20delay=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/dir/response.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/mocks/dir/response.ts b/src/app/mocks/dir/response.ts index d50cd38..af876ec 100644 --- a/src/app/mocks/dir/response.ts +++ b/src/app/mocks/dir/response.ts @@ -6,7 +6,7 @@ import { errorMessage } from '../consts/error'; const delayTime = Math.random() * 4001; export async function createHttpSuccessResponse(data: T) { - await delay(delayTime); + // await delay(delayTime); return HttpResponse.json( { @@ -18,7 +18,7 @@ export async function createHttpSuccessResponse(data: T) { } export async function createHttpErrorResponse(code: keyof typeof errorMessage) { - await delay(delayTime); + // await delay(delayTime); return HttpResponse.json( { From 4c6014196597bd423e07048135b545cdc43062bc Mon Sep 17 00:00:00 2001 From: BangDori Date: Fri, 10 May 2024 20:19:34 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20delay=20default=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=A9=94=ED=84=B0=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mocks/dir/response.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/app/mocks/dir/response.ts b/src/app/mocks/dir/response.ts index af876ec..5498416 100644 --- a/src/app/mocks/dir/response.ts +++ b/src/app/mocks/dir/response.ts @@ -2,11 +2,8 @@ import { HttpResponse, delay } from 'msw'; import { errorMessage } from '../consts/error'; -/** 0 <= 응답 시간 <= 4초 */ -const delayTime = Math.random() * 4001; - export async function createHttpSuccessResponse(data: T) { - // await delay(delayTime); + await delay(); return HttpResponse.json( { @@ -18,7 +15,7 @@ export async function createHttpSuccessResponse(data: T) { } export async function createHttpErrorResponse(code: keyof typeof errorMessage) { - // await delay(delayTime); + await delay(); return HttpResponse.json( {