1 import * as request from 'supertest'
3 type VideoChannelAttributes = {
9 function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
10 const path = '/api/v1/video-channels'
12 const req = request(url)
14 .query({ start: start })
15 .query({ count: count })
17 if (sort) req.query({ sort })
19 return req.set('Accept', 'application/json')
21 .expect('Content-Type', /json/)
24 function getAccountVideoChannelsList (url: string, accountId: number | string, specialStatus = 200) {
25 const path = '/api/v1/accounts/' + accountId + '/video-channels'
29 .set('Accept', 'application/json')
30 .expect(specialStatus)
31 .expect('Content-Type', /json/)
34 function addVideoChannel (
37 videoChannelAttributesArg: VideoChannelAttributes,
40 const path = '/api/v1/video-channels/'
44 name: 'my super video channel',
45 description: 'my super channel description',
46 support: 'my super channel support'
48 attributes = Object.assign(attributes, videoChannelAttributesArg)
53 .set('Accept', 'application/json')
54 .set('Authorization', 'Bearer ' + token)
55 .expect(expectedStatus)
58 function updateVideoChannel (
61 channelId: number | string,
62 attributes: VideoChannelAttributes,
66 const path = '/api/v1/video-channels/' + channelId
68 if (attributes.name) body['name'] = attributes.name
69 if (attributes.description) body['description'] = attributes.description
70 if (attributes.support) body['support'] = attributes.support
75 .set('Accept', 'application/json')
76 .set('Authorization', 'Bearer ' + token)
77 .expect(expectedStatus)
80 function deleteVideoChannel (url: string, token: string, channelId: number | string, expectedStatus = 204) {
81 const path = '/api/v1/video-channels/' + channelId
85 .set('Accept', 'application/json')
86 .set('Authorization', 'Bearer ' + token)
87 .expect(expectedStatus)
90 function getVideoChannel (url: string, channelId: number | string) {
91 const path = '/api/v1/video-channels/' + channelId
95 .set('Accept', 'application/json')
97 .expect('Content-Type', /json/)
100 // ---------------------------------------------------------------------------
103 getVideoChannelsList,
104 getAccountVideoChannelsList,