From 07b1a18aa678d260009a93e36606c5c5f585723d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Feb 2019 11:14:26 +0100 Subject: Add playlist check param tests --- shared/utils/index.ts | 3 ++- shared/utils/videos/video-playlists.ts | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'shared/utils') diff --git a/shared/utils/index.ts b/shared/utils/index.ts index 156901372..c09565d95 100644 --- a/shared/utils/index.ts +++ b/shared/utils/index.ts @@ -13,12 +13,13 @@ export * from './requests/requests' export * from './requests/check-api-params' export * from './server/servers' export * from './videos/services' +export * from './videos/video-playlists' export * from './users/users' export * from './videos/video-abuses' export * from './videos/video-blacklist' export * from './videos/video-channels' export * from './videos/video-comments' -export * from './videos/video-playlists' +export * from './videos/video-streaming-playlists' export * from './videos/videos' export * from './videos/video-change-ownership' export * from './feeds/feeds' diff --git a/shared/utils/videos/video-playlists.ts b/shared/utils/videos/video-playlists.ts index 5186d9c4f..21285688a 100644 --- a/shared/utils/videos/video-playlists.ts +++ b/shared/utils/videos/video-playlists.ts @@ -31,7 +31,7 @@ function getVideoPlaylist (url: string, playlistId: number | string, statusCodeE }) } -function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = 200) { +function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = 204) { const path = '/api/v1/video-playlists/' + playlistId return makeDeleteRequest({ @@ -46,7 +46,7 @@ function createVideoPlaylist (options: { url: string, token: string, playlistAttrs: VideoPlaylistCreate, - expectedStatus: number + expectedStatus?: number }) { const path = '/api/v1/video-playlists/' @@ -63,7 +63,7 @@ function createVideoPlaylist (options: { token: options.token, fields, attaches, - statusCodeExpected: options.expectedStatus + statusCodeExpected: options.expectedStatus || 200 }) } @@ -71,9 +71,10 @@ function updateVideoPlaylist (options: { url: string, token: string, playlistAttrs: VideoPlaylistUpdate, - expectedStatus: number + playlistId: number | string, + expectedStatus?: number }) { - const path = '/api/v1/video-playlists/' + const path = '/api/v1/video-playlists/' + options.playlistId const fields = omit(options.playlistAttrs, 'thumbnailfile') @@ -88,7 +89,7 @@ function updateVideoPlaylist (options: { token: options.token, fields, attaches, - statusCodeExpected: options.expectedStatus + statusCodeExpected: options.expectedStatus || 204 }) } @@ -97,7 +98,7 @@ function addVideoInPlaylist (options: { token: string, playlistId: number | string, elementAttrs: VideoPlaylistElementCreate - expectedStatus: number + expectedStatus?: number }) { const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' @@ -106,7 +107,7 @@ function addVideoInPlaylist (options: { path, token: options.token, fields: options.elementAttrs, - statusCodeExpected: options.expectedStatus + statusCodeExpected: options.expectedStatus || 200 }) } @@ -116,7 +117,7 @@ function updateVideoPlaylistElement (options: { playlistId: number | string, videoId: number | string, elementAttrs: VideoPlaylistElementUpdate, - expectedStatus: number + expectedStatus?: number }) { const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.videoId @@ -125,7 +126,7 @@ function updateVideoPlaylistElement (options: { path, token: options.token, fields: options.elementAttrs, - statusCodeExpected: options.expectedStatus + statusCodeExpected: options.expectedStatus || 204 }) } @@ -142,7 +143,7 @@ function removeVideoFromPlaylist (options: { url: options.url, path, token: options.token, - statusCodeExpected: options.expectedStatus + statusCodeExpected: options.expectedStatus || 204 }) } @@ -152,14 +153,14 @@ function reorderVideosPlaylist (options: { playlistId: number | string, elementAttrs: { startPosition: number, - insertAfter: number, + insertAfterPosition: number, reorderLength?: number }, expectedStatus: number }) { - const path = '/api/v1/video-playlists/' + options.playlistId + '/videos' + const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/reorder' - return makePutBodyRequest({ + return makePostBodyRequest({ url: options.url, path, token: options.token, @@ -179,6 +180,7 @@ export { deleteVideoPlaylist, addVideoInPlaylist, + updateVideoPlaylistElement, removeVideoFromPlaylist, reorderVideosPlaylist -- cgit v1.2.3