aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-comments.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/video-comments.ts')
-rw-r--r--server/tests/api/check-params/video-comments.ts64
1 files changed, 31 insertions, 33 deletions
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index f3832bd2c..cdb48a276 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -1,8 +1,11 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha' 3import 'mocha'
4import * as request from 'supertest' 4import {
5import { flushTests, killallServers, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils' 5 flushTests, killallServers, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers,
6 uploadVideo
7} from '../../utils'
8import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
6import { addVideoCommentThread } from '../../utils/videos/video-comments' 9import { addVideoCommentThread } from '../../utils/videos/video-comments'
7 10
8describe('Test video comments API validator', function () { 11describe('Test video comments API validator', function () {
@@ -38,57 +41,52 @@ describe('Test video comments API validator', function () {
38 41
39 describe('When listing video comment threads', function () { 42 describe('When listing video comment threads', function () {
40 it('Should fail with a bad start pagination', async function () { 43 it('Should fail with a bad start pagination', async function () {
41 await request(server.url) 44 await checkBadStartPagination(server.url, pathThread, server.accessToken)
42 .get(pathThread) 45
43 .query({ start: 'hello' })
44 .set('Accept', 'application/json')
45 .expect(400)
46 }) 46 })
47 47
48 it('Should fail with a bad count pagination', async function () { 48 it('Should fail with a bad count pagination', async function () {
49 await request(server.url) 49 await checkBadCountPagination(server.url, pathThread, server.accessToken)
50 .get(pathThread) 50
51 .query({ count: 'hello' })
52 .set('Accept', 'application/json')
53 .expect(400)
54 }) 51 })
55 52
56 it('Should fail with an incorrect sort', async function () { 53 it('Should fail with an incorrect sort', async function () {
57 await request(server.url) 54 await checkBadSortPagination(server.url, pathThread, server.accessToken)
58 .get(pathThread) 55
59 .query({ sort: 'hello' })
60 .set('Accept', 'application/json')
61 .expect(400)
62 }) 56 })
63 57
64 it('Should fail with an incorrect video', async function () { 58 it('Should fail with an incorrect video', async function () {
65 await request(server.url) 59 await makeGetRequest({
66 .get('/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads') 60 url: server.url,
67 .set('Accept', 'application/json') 61 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads',
68 .expect(404) 62 statusCodeExpected: 404
63 })
69 }) 64 })
70 }) 65 })
71 66
72 describe('When listing comments of a thread', function () { 67 describe('When listing comments of a thread', function () {
73 it('Should fail with an incorrect video', async function () { 68 it('Should fail with an incorrect video', async function () {
74 await request(server.url) 69 await makeGetRequest({
75 .get('/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId) 70 url: server.url,
76 .set('Accept', 'application/json') 71 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId,
77 .expect(404) 72 statusCodeExpected: 404
73 })
78 }) 74 })
79 75
80 it('Should fail with an incorrect thread id', async function () { 76 it('Should fail with an incorrect thread id', async function () {
81 await request(server.url) 77 await makeGetRequest({
82 .get('/api/v1/videos/' + videoUUID + '/comment-threads/156') 78 url: server.url,
83 .set('Accept', 'application/json') 79 path: '/api/v1/videos/' + videoUUID + '/comment-threads/156',
84 .expect(404) 80 statusCodeExpected: 404
81 })
85 }) 82 })
86 83
87 it('Should success with the correct params', async function () { 84 it('Should success with the correct params', async function () {
88 await request(server.url) 85 await makeGetRequest({
89 .get('/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId) 86 url: server.url,
90 .set('Accept', 'application/json') 87 path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId,
91 .expect(200) 88 statusCodeExpected: 200
89 })
92 }) 90 })
93 }) 91 })
94 92