-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8ad72a
commit c55c06d
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HttpResponse, http } from 'msw'; | ||
|
||
import { COMMON_RES } from './common.responses'; | ||
|
||
export const COMMON_MOCK_URL = { | ||
GET_URL_NAME: 'api/v2/tabName', | ||
}; | ||
|
||
export const commonResolvers = [ | ||
http.get(COMMON_MOCK_URL.GET_URL_NAME, async ({ request }) => { | ||
const url = new URL(request.url); | ||
const tabName = url.searchParams.get('tabName'); | ||
|
||
if (!tabName) { | ||
console.error('경로 파라미터에 tabName이 없습니다.'); | ||
throw new HttpResponse(null, { status: 400 }); | ||
} | ||
|
||
return HttpResponse.json(COMMON_RES.GET_URL_NAME); | ||
}), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const COMMON_RES = { | ||
GET_URL_NAME: { | ||
status: 200, | ||
message: '요청이 성공했습니다.', | ||
data: { | ||
tabName: 'NAVER', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { commonResolvers } from './common/common.resolvers'; | ||
import { homeResolvers } from './home/resolvers/homeResolvers'; | ||
import { onboardingResolvers } from './onboarding/onboarding.resolvers'; | ||
|
||
export const handlers = [...homeResolvers]; | ||
export const handlers = [...homeResolvers, ...onboardingResolvers, ...commonResolvers]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { HttpResponse, http } from 'msw'; | ||
|
||
import { ONBOARDING_RES } from './onboarding.responses'; | ||
|
||
export const ONBOARDING_MOCK_URL = { | ||
POST_INTEREST_AREA: 'api/v2/onboard', | ||
}; | ||
|
||
export const onboardingResolvers = [ | ||
http.post<never, { siteName: string; siteUrl: string }[]>( | ||
ONBOARDING_MOCK_URL.POST_INTEREST_AREA, | ||
async ({ request }) => { | ||
const url = new URL(request.url); | ||
const interestArea = url.searchParams.get('interestArea'); | ||
|
||
const body = await request.json(); | ||
|
||
if (body.length === 0) return HttpResponse.json(ONBOARDING_RES.POST_INTEREST_AREA); | ||
|
||
if ( | ||
!(body.length > 0 && (typeof body[0].siteName === 'string' || typeof body[0].siteUrl === 'string')) || | ||
!interestArea | ||
) { | ||
console.error('요청 바디 값과, 쿼리스트링 값을 확인해주세요'); | ||
throw new HttpResponse(null, { status: 400 }); | ||
} | ||
|
||
return HttpResponse.json(ONBOARDING_RES.POST_INTEREST_AREA); | ||
}, | ||
), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const ONBOARDING_RES = { | ||
POST_INTEREST_AREA: { | ||
status: 200, | ||
message: '요청이 성공했습니다.', | ||
}, | ||
}; |