1 import * as request from 'supertest'
3 type VideoChannelAttributes = {
8 function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
9 const path = '/api/v1/videos/channels'
11 const req = request(url)
13 .query({ start: start })
14 .query({ count: count })
16 if (sort) req.query({ sort })
18 return req.set('Accept', 'application/json')
20 .expect('Content-Type', /json/)
23 function getAccountVideoChannelsList (url: string, accountId: number | string) {
24 const path = '/api/v1/videos/accounts/' + accountId + '/channels'
28 .set('Accept', 'application/json')
30 .expect('Content-Type', /json/)
33 function addVideoChannel (url: string, token: string, videoChannelAttributesArg: VideoChannelAttributes, expectedStatus = 204) {
34 const path = '/api/v1/videos/channels'
38 name: 'my super video channel',
39 description: 'my super channel description'
41 attributes = Object.assign(attributes, videoChannelAttributesArg)
46 .set('Accept', 'application/json')
47 .set('Authorization', 'Bearer ' + token)
48 .expect(expectedStatus)
51 function updateVideoChannel (url: string, token: string, channelId: number, attributes: VideoChannelAttributes, expectedStatus = 204) {
53 const path = '/api/v1/videos/channels/' + channelId
55 if (attributes.name) body['name'] = attributes.name
56 if (attributes.description) body['description'] = attributes.description
61 .set('Accept', 'application/json')
62 .set('Authorization', 'Bearer ' + token)
63 .expect(expectedStatus)
66 function deleteVideoChannel (url: string, token: string, channelId: number, expectedStatus = 204) {
67 const path = '/api/v1/videos/channels/'
70 .delete(path + channelId)
71 .set('Accept', 'application/json')
72 .set('Authorization', 'Bearer ' + token)
73 .expect(expectedStatus)
76 function getVideoChannel (url: string, channelId: number) {
77 const path = '/api/v1/videos/channels/' + channelId
81 .set('Accept', 'application/json')
83 .expect('Content-Type', /json/)
86 // ---------------------------------------------------------------------------
90 getAccountVideoChannelsList,