]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/jobs.ts
Handle higher FPS for high resolution (test)
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / jobs.ts
index 3795d1d64d8dbfea0dfebebb9dedda6891d8f808..ce3ac880920f1dea9b40cf20b6980e2d4ad9dd53 100644 (file)
@@ -1,12 +1,13 @@
 /* tslint:disable:no-unused-expression */
 
 import 'mocha'
-import * as request from 'supertest'
 
-import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils'
+import { createUser, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, userLogin } from '../../utils'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
+import { makeGetRequest } from '../../utils/requests/requests'
 
 describe('Test jobs API validators', function () {
-  const path = '/api/v1/jobs/'
+  const path = '/api/v1/jobs/failed'
   let server: ServerInfo
   let userAccessToken = ''
 
@@ -30,46 +31,42 @@ describe('Test jobs API validators', function () {
   })
 
   describe('When listing jobs', function () {
+
+    it('Should fail with a bad state', async function () {
+      await makeGetRequest({
+        url: server.url,
+        token: server.accessToken,
+        path: path + 'ade'
+      })
+    })
+
     it('Should fail with a bad start pagination', async function () {
-      await request(server.url)
-              .get(path)
-              .query({ start: 'hello' })
-              .set('Accept', 'application/json')
-              .set('Authorization', 'Bearer ' + server.accessToken)
-              .expect(400)
+      await checkBadStartPagination(server.url, path, server.accessToken)
     })
 
     it('Should fail with a bad count pagination', async function () {
-      await request(server.url)
-              .get(path)
-              .query({ count: 'hello' })
-              .set('Accept', 'application/json')
-              .set('Authorization', 'Bearer ' + server.accessToken)
-              .expect(400)
+      await checkBadCountPagination(server.url, path, server.accessToken)
     })
 
     it('Should fail with an incorrect sort', async function () {
-      await request(server.url)
-              .get(path)
-              .query({ sort: 'hello' })
-              .set('Accept', 'application/json')
-              .set('Authorization', 'Bearer ' + server.accessToken)
-              .expect(400)
+      await checkBadSortPagination(server.url, path, server.accessToken)
     })
 
     it('Should fail with a non authenticated user', async function () {
-      await request(server.url)
-        .get(path)
-        .set('Accept', 'application/json')
-        .expect(401)
+      await makeGetRequest({
+        url: server.url,
+        path,
+        statusCodeExpected: 401
+      })
     })
 
     it('Should fail with a non admin user', async function () {
-      await request(server.url)
-        .get(path)
-        .set('Accept', 'application/json')
-        .set('Authorization', 'Bearer ' + userAccessToken)
-        .expect(403)
+      await makeGetRequest({
+        url: server.url,
+        path,
+        token: userAccessToken,
+        statusCodeExpected: 403
+      })
     })
   })