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 accountId: number | string,
38 videoChannelAttributesArg: VideoChannelAttributes,
41 const path = '/api/v1/accounts/' + accountId + '/video-channels/'
45 name: 'my super video channel',
46 description: 'my super channel description',
47 support: 'my super channel support'
49 attributes = Object.assign(attributes, videoChannelAttributesArg)
54 .set('Accept', 'application/json')
55 .set('Authorization', 'Bearer ' + token)
56 .expect(expectedStatus)
59 function updateVideoChannel (
62 accountId: number | string,
63 channelId: number | string,
64 attributes: VideoChannelAttributes,
68 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId
70 if (attributes.name) body['name'] = attributes.name
71 if (attributes.description) body['description'] = attributes.description
72 if (attributes.support) body['support'] = attributes.support
77 .set('Accept', 'application/json')
78 .set('Authorization', 'Bearer ' + token)
79 .expect(expectedStatus)
82 function deleteVideoChannel (url: string, token: string, accountId: number | string, channelId: number | string, expectedStatus = 204) {
83 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId
87 .set('Accept', 'application/json')
88 .set('Authorization', 'Bearer ' + token)
89 .expect(expectedStatus)
92 function getVideoChannel (url: string, accountId: number | string, channelId: number | string) {
93 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId
97 .set('Accept', 'application/json')
99 .expect('Content-Type', /json/)
102 // ---------------------------------------------------------------------------
105 getVideoChannelsList,
106 getAccountVideoChannelsList,