1 import * as request from 'supertest'
2 import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared/models/videos'
4 function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
5 const path = '/api/v1/video-channels'
7 const req = request(url)
9 .query({ start: start })
10 .query({ count: count })
12 if (sort) req.query({ sort })
14 return req.set('Accept', 'application/json')
16 .expect('Content-Type', /json/)
19 function getAccountVideoChannelsList (url: string, accountId: number | string, specialStatus = 200) {
20 const path = '/api/v1/accounts/' + accountId + '/video-channels'
24 .set('Accept', 'application/json')
25 .expect(specialStatus)
26 .expect('Content-Type', /json/)
29 function addVideoChannel (
32 videoChannelAttributesArg: VideoChannelCreate,
35 const path = '/api/v1/video-channels/'
39 displayName: 'my super video channel',
40 description: 'my super channel description',
41 support: 'my super channel support'
43 attributes = Object.assign(attributes, videoChannelAttributesArg)
48 .set('Accept', 'application/json')
49 .set('Authorization', 'Bearer ' + token)
50 .expect(expectedStatus)
53 function updateVideoChannel (
56 channelId: number | string,
57 attributes: VideoChannelUpdate,
61 const path = '/api/v1/video-channels/' + channelId
63 if (attributes.displayName) body['displayName'] = attributes.displayName
64 if (attributes.description) body['description'] = attributes.description
65 if (attributes.support) body['support'] = attributes.support
70 .set('Accept', 'application/json')
71 .set('Authorization', 'Bearer ' + token)
72 .expect(expectedStatus)
75 function deleteVideoChannel (url: string, token: string, channelId: number | string, expectedStatus = 204) {
76 const path = '/api/v1/video-channels/' + channelId
80 .set('Accept', 'application/json')
81 .set('Authorization', 'Bearer ' + token)
82 .expect(expectedStatus)
85 function getVideoChannel (url: string, channelId: number | string) {
86 const path = '/api/v1/video-channels/' + channelId
90 .set('Accept', 'application/json')
92 .expect('Content-Type', /json/)
95 // ---------------------------------------------------------------------------
99 getAccountVideoChannelsList,