Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NDD-132] video api mocking 추가 (2h / 2h) #39

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FE/src/constants/api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
export const BASE_URL = '';

type Id = number;
type Hash = string;

export const API = {
MEMBER: '/member',
VIDEO: '/video',
VIDEO_PRE_SIGNED: '/video/pre-signed',
VIDEO_ALL: '/video/all',
VIDEO_ID: (id?: Id) => `/video/${id ?? ':id'}`,
VIDEO_HASH: (hash?: Hash) => `/video/hash/${hash ?? ':hash'}`,
QUESTION: '/question',
QUESTION_ID: (id?: Id) => `/question/${id ?? ':id'}`,
ANSWER: '/answer',
Expand Down
3 changes: 2 additions & 1 deletion FE/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { http, HttpResponse } from 'msw';
import memberHandlers from './handlers/member';
import questionHandlers from './handlers/question';
import answerHandlers from './handlers/answer';
import videoHandlers from '@/mocks/handlers/video';

export const handlers = [
...memberHandlers,
...questionHandlers,
...answerHandlers,
...videoHandlers,
];
80 changes: 80 additions & 0 deletions FE/src/mocks/handlers/video.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { API } from '@/constants/api';
import { http, HttpResponse } from 'msw';

const videoHandlers = [
http.post(API.VIDEO, ({ request }) => {
return HttpResponse.json({}, { status: 201 });
}),
http.post(API.VIDEO_PRE_SIGNED, ({ request }) => {
return HttpResponse.json(
{
preSignedUrl:
'https://videos.k4i7.la.idrivee2-20.com/%EB%A3%A8%EC%9D%B4%EB%B7%94%ED%86%B5%ED%86%B5%ED%8A%80%EA%B8%B0%EB%84%A4_%EC%82%AD%EC%A0%9C%EB%90%9C%20%EC%A7%88%EB%AC%B8_754ad469-a5e7-48a2-b6bd-61430219c831.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=9li5IlcqRaLakjxoO16x%2F20231114%2Fe2%2Fs3%2Faws4_request&X-Amz-Date=20231114T060953Z&X-Amz-Expires=100&X-Amz-Signature=48691d27634299f2ad74ae7812b49e2bd88a0f8ab677b6b19ba0fc3921b08d24&X-Amz-SignedHeaders=host',
key: 'Idrive에 등록될 파일 이름입니다.',
},
{ status: 201 }
);
}),
http.get(API.VIDEO_ALL, () => {
return HttpResponse.json(
[
{
id: 1,
videoName: 'CSS 선택자의 종류에 대해 설명해주세요.',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ElephantsDream.jpg',
videoLength: '10:53',
isPublic: false,
createdAt: '1699941626145',
},
{
id: 2,
videoName: 'Big Buck Bunny',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg',
videoLength: '07:17',
isPublic: true,
createdAt: '1699941626145',
},
{
id: 3,
videoName: 'Elephant Dream',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerBlazes.jpg',
videoLength: '03:00',
isPublic: false,
createdAt: '1699941626145',
},
],
{ status: 200 }
);
}),
http.get(API.VIDEO_ID(), () => {
return HttpResponse.json(
[
{
id: 1,
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
hash: 'asdfasdfasdfsfasdfasf',
videoName: 'CSS 선택자의 종류에 대해 설명해주세요.',
milk717 marked this conversation as resolved.
Show resolved Hide resolved
createdAt: '1699941626145',
},
],
{ status: 200 }
);
}),
http.get(API.VIDEO_HASH(), () => {
return HttpResponse.json(
{ hash: 'hashstringstringsrting' },
{ status: 200 }
);
}),
http.patch(API.VIDEO_ID(), () => {
return HttpResponse.json(null, { status: 204 });
}),
http.delete(API.VIDEO_ID(), ({ request }) => {
return HttpResponse.json(null, { status: 204 });
}),
];

export default videoHandlers;
Loading