Skip to content

Commit

Permalink
feat: add msw handler
Browse files Browse the repository at this point in the history
  • Loading branch information
timepresent95 committed Aug 9, 2024
1 parent 4cb2b6f commit 4ca44e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/mocks/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
import {http, HttpResponse} from 'msw';

import {mockMembers} from './mockUser';

import {API_BASE_URL} from '@/constants/api';

const getHandlers = [
http.get(API_BASE_URL + '/auth/signout', () => {
http.get(API_BASE_URL + '/auth/oauth/sign-out', () => {
return HttpResponse.json({});
}),
http.get(API_BASE_URL + '/question/today', () => {
return HttpResponse.json({
question: '오늘의 질문 샘플 질문입니다',
});
return HttpResponse.json({question: '오늘의 질문 입니다!'});
}),
http.get(API_BASE_URL + '/members', () => {
return HttpResponse.json({});
return HttpResponse.json({
members: mockMembers,
});
}),
];

const postHandlers = [
http.post(API_BASE_URL + '/auth/signup', () => {
return HttpResponse.json({
token: 'token',
name: 'test',
role: 'son',
});
http.post(API_BASE_URL + '/auth/oauth/log-in', () => {
return HttpResponse.json({});
}),
http.post(API_BASE_URL + '/auth/signin', () => {
return HttpResponse.json({
token: 'token',
name: 'test',
role: 'son',
});
http.post(API_BASE_URL + '/auth/oauth/sign-up', () => {
return HttpResponse.json({});
}),
];

Expand Down
5 changes: 5 additions & 0 deletions src/mocks/handlers/mockUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {createUser} from '../fakers';

import {Member} from '@/types';

export const mockMembers: Member[] = Array.from({length: 5}, createUser);

0 comments on commit 4ca44e8

Please sign in to comment.