aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/video-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 13:59:22 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 13:59:22 +0100
commitc5d31dba56d669c0df0209761c43c5a6ac7cec4a (patch)
treefe72b56a1c0e7beb6e092c393a00ddfe93a5d71f /server/tests/utils/video-channels.ts
parentdb799da3d2b2ea465165df78ff71effa653b6309 (diff)
downloadPeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.gz
PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.zst
PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.zip
Tests directories refractor
Diffstat (limited to 'server/tests/utils/video-channels.ts')
-rw-r--r--server/tests/utils/video-channels.ts95
1 files changed, 0 insertions, 95 deletions
diff --git a/server/tests/utils/video-channels.ts b/server/tests/utils/video-channels.ts
deleted file mode 100644
index 0fb80d331..000000000
--- a/server/tests/utils/video-channels.ts
+++ /dev/null
@@ -1,95 +0,0 @@
1import * as request from 'supertest'
2
3type VideoChannelAttributes = {
4 name?: string
5 description?: string
6}
7
8function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
9 const path = '/api/v1/videos/channels'
10
11 const req = request(url)
12 .get(path)
13 .query({ start: start })
14 .query({ count: count })
15
16 if (sort) req.query({ sort })
17
18 return req.set('Accept', 'application/json')
19 .expect(200)
20 .expect('Content-Type', /json/)
21}
22
23function getAccountVideoChannelsList (url: string, accountId: number | string) {
24 const path = '/api/v1/videos/accounts/' + accountId + '/channels'
25
26 return request(url)
27 .get(path)
28 .set('Accept', 'application/json')
29 .expect(200)
30 .expect('Content-Type', /json/)
31}
32
33function addVideoChannel (url: string, token: string, videoChannelAttributesArg: VideoChannelAttributes, expectedStatus = 204) {
34 const path = '/api/v1/videos/channels'
35
36 // Default attributes
37 let attributes = {
38 name: 'my super video channel',
39 description: 'my super channel description'
40 }
41 attributes = Object.assign(attributes, videoChannelAttributesArg)
42
43 return request(url)
44 .post(path)
45 .send(attributes)
46 .set('Accept', 'application/json')
47 .set('Authorization', 'Bearer ' + token)
48 .expect(expectedStatus)
49}
50
51function updateVideoChannel (url: string, token: string, channelId: number, attributes: VideoChannelAttributes, expectedStatus = 204) {
52 const body = {}
53 const path = '/api/v1/videos/channels/' + channelId
54
55 if (attributes.name) body['name'] = attributes.name
56 if (attributes.description) body['description'] = attributes.description
57
58 return request(url)
59 .put(path)
60 .send(body)
61 .set('Accept', 'application/json')
62 .set('Authorization', 'Bearer ' + token)
63 .expect(expectedStatus)
64}
65
66function deleteVideoChannel (url: string, token: string, channelId: number, expectedStatus = 204) {
67 const path = '/api/v1/videos/channels/'
68
69 return request(url)
70 .delete(path + channelId)
71 .set('Accept', 'application/json')
72 .set('Authorization', 'Bearer ' + token)
73 .expect(expectedStatus)
74}
75
76function getVideoChannel (url: string, channelId: number) {
77 const path = '/api/v1/videos/channels/' + channelId
78
79 return request(url)
80 .get(path)
81 .set('Accept', 'application/json')
82 .expect(200)
83 .expect('Content-Type', /json/)
84}
85
86// ---------------------------------------------------------------------------
87
88export {
89 getVideoChannelsList,
90 getAccountVideoChannelsList,
91 addVideoChannel,
92 updateVideoChannel,
93 deleteVideoChannel,
94 getVideoChannel
95}