Skip to content

Commit

Permalink
[NDD-132] video api mocking 추가 (2h / 2h) (#39)
Browse files Browse the repository at this point in the history
* test: video api mocking 추가

- 일단 명세대로 만들었으나 의문이 드는 부분과 변경 요청을 드리고 싶은 부분이 있어서 2023.11.14일에 대면으로 만나서 의논할 예정

* test: video api mocking 완료

* test: video api name 필드의 이름을 videoName으로 변경
  • Loading branch information
milk717 authored Nov 15, 2023
1 parent 0518004 commit 80f7b9b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
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 선택자의 종류에 대해 설명해주세요.',
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;

0 comments on commit 80f7b9b

Please sign in to comment.