-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NDD-132] video api mocking 추가 (2h / 2h) (#39)
* test: video api mocking 추가 - 일단 명세대로 만들었으나 의문이 드는 부분과 변경 요청을 드리고 싶은 부분이 있어서 2023.11.14일에 대면으로 만나서 의논할 예정 * test: video api mocking 완료 * test: video api name 필드의 이름을 videoName으로 변경
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |