Skip to content

Commit

Permalink
test: video api mocking 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
milk717 committed Nov 14, 2023
1 parent 672bb42 commit 242e683
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion FE/src/constants/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const API = {
VIDEO_PRE_SIGNED: '/video/pre-signed',
VIDEO_ALL: '/video/all',
VIDEO_ID: (id?: Id) => `/video/${id ?? ':id'}`,
VIDEO_HASH: (hash?: Hash) => `/video/${hash ?? ':hash'}`,
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,
];
39 changes: 20 additions & 19 deletions FE/src/mocks/handlers/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,44 @@ const videoHandlers = [
return HttpResponse.json({}, { status: 201 });
}),
http.post(API.VIDEO_PRE_SIGNED, ({ request }) => {
return HttpResponse.json({}, { status: 201 });
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,
questionId: 1,
name: 'CSS 선택자의 종류에 대해 설명해주세요.',
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
videoName: 'CSS 선택자의 종류에 대해 설명해주세요.',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ElephantsDream.jpg',
videoLength: '00:10:53',
videoLength: '10:53',
isPublic: false,
createdAt: '2023-11-12 08:22:12',
createdAt: '1699941626145',
},
{
id: 2,
questionId: 1,
name: 'Big Buck Bunny',
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
videoName: 'Big Buck Bunny',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg',
videoLength: '',
videoLength: '07:17',
isPublic: true,
createdAt: '2001-07-17 08:22:12',
createdAt: '1699941626145',
},
{
id: 3,
questionId: 1,
name: 'Elephant Dream',
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4',
videoName: 'Elephant Dream',
thumbnail:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerBlazes.jpg',
videoLength: '',
videoLength: '03:00',
isPublic: false,
createdAt: '2023-11-11 08:22:12',
createdAt: '1699941626145',
},
],
{ status: 200 }
Expand All @@ -53,10 +54,10 @@ const videoHandlers = [
[
{
id: 1,
questionId: 1,
name: 'CSS 선택자의 종류에 대해 설명해주세요.',
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
createdAt: '2023-11-12 08:22:12',
hash: 'asdfasdfasdfsfasdfasf',
name: 'CSS 선택자의 종류에 대해 설명해주세요.',
createdAt: '1699941626145',
},
],
{ status: 200 }
Expand Down

0 comments on commit 242e683

Please sign in to comment.