Skip to content

Commit

Permalink
feat: review detail msw 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
hayoung123 committed Oct 14, 2022
1 parent 148ad1d commit 28f13d8
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/api/mock/handlers/review.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from 'msw';
import { ReviewDetailType } from 'src/types/api/review';
import sampleImage from '../../../../public/assets/image/sample.jpeg';

const REVIEW_LIST_MOCK = {
Expand All @@ -16,30 +17,28 @@ const REVIEW_LIST_MOCK = {
],
};

const REVIEW_MOCK = {
const REVIEW_DETAIL_MOCK: ReviewDetailType = {
id: 1,
concertHall: '올림픽홀',
user: {
id: 12,
email: 'seeya@gmail.com',
kakaoId: 'seeya',
nickname: 'seeya-tester',
},
concertHallName: '올림픽홀',
imageUrlArray: [sampleImage.src, sampleImage.src],
images: [sampleImage.src, sampleImage.src],
createAt: '2021-09-22T16:15:45+09:00',
updateAt: '2021-09-22T16:15:45+09:00',
seatArea: 'B1',
images: [sampleImage, '/media/review-images/05_2021-09-22T07:15:45.000Z_.jpg'],
artist: null,
artist: 'seeya-singer',
review: '너무 좋아요',
comments: ['리뷰 테스트1', '리뷰 테스트2', '리뷰 테스트3'],
likeUsers: [],
nextId: 13,
previousId: null,
previousId: 2,
};

// export const getReviewDetailAPI = async (seatAreaId: number, reviewId: number): Promise<ReviewDetailType> => {
// const { data } = await axios.get(`/seat_areas/${seatAreaId}/reviews/${reviewId}`);

// return data;
// };

// export const getReviewListAPI = async (seatId: number, page: number): Promise<ReviewListType> => {
// const { data } = await axios.get(`/seat_areas/${seatId}/reviews?page=${page}`);

// return data;
// };

// export const getReviewCommentListAPI = async (reviewId: number): Promise<ReviewCommentType[]> => {
// const { data } = await axios.get(`/reviews/${reviewId}/comments`);

Expand All @@ -58,6 +57,14 @@ export const getReviewListAPIHandler = rest.get(
return res(ctx.json(REVIEW_LIST_MOCK));
},
);

export const getReviewDetailAPIHandler = rest.get(
`${process.env.NEXT_PUBLIC_HOST}/seat_areas/:seatAreaId/reviews/:reviewId`,
(req, res, ctx) => {
return res(ctx.json(REVIEW_DETAIL_MOCK));
},
);

// export const reviewHandlers = [
// rest.get(`${process.env.NEXT_PUBLIC_HOST}/seat_areas/:seatAreaId/reviews`, (req, res, ctx) => {
// return res(ctx.json({ results: [REVIEW_MOCK] }));
Expand Down

0 comments on commit 28f13d8

Please sign in to comment.