From 2d53be0267acc49cda46707b885096193a1f4e9c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 7 Dec 2020 14:32:36 +0100 Subject: replace numbers with typed http status codes (#3409) --- shared/extra-utils/videos/video-comments.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'shared/extra-utils/videos/video-comments.ts') 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 @@ import * as request from 'supertest' import { makeDeleteRequest, makeGetRequest } from '../requests/requests' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' function getAdminVideoComments (options: { url: string @@ -33,7 +34,7 @@ function getAdminVideoComments (options: { path, token, query, - statusCodeExpected: 200 + statusCodeExpected: HttpStatusCode.OK_200 }) } @@ -49,7 +50,7 @@ function getVideoCommentThreads (url: string, videoId: number | string, start: n if (token) req.set('Authorization', 'Bearer ' + token) return req.set('Accept', 'application/json') - .expect(200) + .expect(HttpStatusCode.OK_200) .expect('Content-Type', /json/) } @@ -62,11 +63,17 @@ function getVideoThreadComments (url: string, videoId: number | string, threadId if (token) req.set('Authorization', 'Bearer ' + token) - return req.expect(200) + return req.expect(HttpStatusCode.OK_200) .expect('Content-Type', /json/) } -function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { +function addVideoCommentThread ( + url: string, + token: string, + videoId: number | string, + text: string, + expectedStatus = HttpStatusCode.OK_200 +) { const path = '/api/v1/videos/' + videoId + '/comment-threads' return request(url) @@ -83,7 +90,7 @@ function addVideoCommentReply ( videoId: number | string, inReplyToCommentId: number, text: string, - expectedStatus = 200 + expectedStatus = HttpStatusCode.OK_200 ) { const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId @@ -106,7 +113,7 @@ function deleteVideoComment ( token: string, videoId: number | string, commentId: number, - statusCodeExpected = 204 + statusCodeExpected = HttpStatusCode.NO_CONTENT_204 ) { const path = '/api/v1/videos/' + videoId + '/comments/' + commentId -- cgit v1.2.3