]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/search.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / search.ts
index d35eac7fe2498d8c1e93b62366e98ba6ceeb91fa..f8d0cd4ecea43664d03aa1a03872aee67394d2db 100644 (file)
@@ -1,12 +1,15 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 
-import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../utils'
-import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
+import { cleanupTests, flushAndRunServer, immutableAssign, makeGetRequest, ServerInfo } from '../../../../shared/extra-utils'
+import {
+  checkBadCountPagination,
+  checkBadSortPagination,
+  checkBadStartPagination
+} from '../../../../shared/extra-utils/requests/check-api-params'
 
 describe('Test videos API validator', function () {
-  const path = '/api/v1/search/videos/'
   let server: ServerInfo
 
   // ---------------------------------------------------------------
@@ -14,12 +17,12 @@ describe('Test videos API validator', function () {
   before(async function () {
     this.timeout(30000)
 
-    await flushTests()
-
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
   })
 
   describe('When searching videos', function () {
+    const path = '/api/v1/search/videos/'
+
     const query = {
       search: 'coucou'
     }
@@ -108,15 +111,40 @@ describe('Test videos API validator', function () {
 
       const customQuery2 = immutableAssign(query, { endDate: 'hello' })
       await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: 400 })
+
+      const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' })
+      await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: 400 })
+
+      const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' })
+      await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: 400 })
     })
   })
 
-  after(async function () {
-    killallServers([ server ])
+  describe('When searching video channels', function () {
+    const path = '/api/v1/search/video-channels/'
 
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
+    const query = {
+      search: 'coucou'
     }
+
+    it('Should fail with a bad start pagination', async function () {
+      await checkBadStartPagination(server.url, path, null, query)
+    })
+
+    it('Should fail with a bad count pagination', async function () {
+      await checkBadCountPagination(server.url, path, null, query)
+    })
+
+    it('Should fail with an incorrect sort', async function () {
+      await checkBadSortPagination(server.url, path, null, query)
+    })
+
+    it('Should success with the correct parameters', async function () {
+      await makeGetRequest({ url: server.url, path, query, statusCodeExpected: 200 })
+    })
+  })
+
+  after(async function () {
+    await cleanupTests([ server ])
   })
 })