aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/video-comments.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /shared/extra-utils/videos/video-comments.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'shared/extra-utils/videos/video-comments.ts')
-rw-r--r--shared/extra-utils/videos/video-comments.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/shared/extra-utils/videos/video-comments.ts b/shared/extra-utils/videos/video-comments.ts
index 0b0df81dc..71b9f875a 100644
--- a/shared/extra-utils/videos/video-comments.ts
+++ b/shared/extra-utils/videos/video-comments.ts
@@ -2,6 +2,7 @@
2 2
3import * as request from 'supertest' 3import * as request from 'supertest'
4import { makeDeleteRequest, makeGetRequest } from '../requests/requests' 4import { makeDeleteRequest, makeGetRequest } from '../requests/requests'
5import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
5 6
6function getAdminVideoComments (options: { 7function getAdminVideoComments (options: {
7 url: string 8 url: string
@@ -33,7 +34,7 @@ function getAdminVideoComments (options: {
33 path, 34 path,
34 token, 35 token,
35 query, 36 query,
36 statusCodeExpected: 200 37 statusCodeExpected: HttpStatusCode.OK_200
37 }) 38 })
38} 39}
39 40
@@ -49,7 +50,7 @@ function getVideoCommentThreads (url: string, videoId: number | string, start: n
49 if (token) req.set('Authorization', 'Bearer ' + token) 50 if (token) req.set('Authorization', 'Bearer ' + token)
50 51
51 return req.set('Accept', 'application/json') 52 return req.set('Accept', 'application/json')
52 .expect(200) 53 .expect(HttpStatusCode.OK_200)
53 .expect('Content-Type', /json/) 54 .expect('Content-Type', /json/)
54} 55}
55 56
@@ -62,11 +63,17 @@ function getVideoThreadComments (url: string, videoId: number | string, threadId
62 63
63 if (token) req.set('Authorization', 'Bearer ' + token) 64 if (token) req.set('Authorization', 'Bearer ' + token)
64 65
65 return req.expect(200) 66 return req.expect(HttpStatusCode.OK_200)
66 .expect('Content-Type', /json/) 67 .expect('Content-Type', /json/)
67} 68}
68 69
69function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { 70function addVideoCommentThread (
71 url: string,
72 token: string,
73 videoId: number | string,
74 text: string,
75 expectedStatus = HttpStatusCode.OK_200
76) {
70 const path = '/api/v1/videos/' + videoId + '/comment-threads' 77 const path = '/api/v1/videos/' + videoId + '/comment-threads'
71 78
72 return request(url) 79 return request(url)
@@ -83,7 +90,7 @@ function addVideoCommentReply (
83 videoId: number | string, 90 videoId: number | string,
84 inReplyToCommentId: number, 91 inReplyToCommentId: number,
85 text: string, 92 text: string,
86 expectedStatus = 200 93 expectedStatus = HttpStatusCode.OK_200
87) { 94) {
88 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId 95 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId
89 96
@@ -106,7 +113,7 @@ function deleteVideoComment (
106 token: string, 113 token: string,
107 videoId: number | string, 114 videoId: number | string,
108 commentId: number, 115 commentId: number,
109 statusCodeExpected = 204 116 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
110) { 117) {
111 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId 118 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId
112 119