]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/follows.ts
Add search target check params
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / follows.ts
index e75631312018be728c20c9c79b00ed6627191b65..2c2224a452b848a972362b6d06505b76ee78ec47 100644 (file)
@@ -1,9 +1,15 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 
 import {
-  createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers,
+  cleanupTests,
+  createUser,
+  flushAndRunServer,
+  makeDeleteRequest, makeGetRequest,
+  makePostBodyRequest,
+  ServerInfo,
+  setAccessTokensToServers,
   userLogin
 } from '../../../../shared/extra-utils'
 import {
@@ -20,8 +26,7 @@ describe('Test server follows API validators', function () {
   before(async function () {
     this.timeout(30000)
 
-    await flushTests()
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
 
     await setAccessTokensToServers([ server ])
   })
@@ -126,6 +131,38 @@ describe('Test server follows API validators', function () {
       it('Should fail with an incorrect sort', async function () {
         await checkBadSortPagination(server.url, path)
       })
+
+      it('Should fail with an incorrect state', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          query: {
+            state: 'blabla'
+          }
+        })
+      })
+
+      it('Should fail with an incorrect actor type', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          query: {
+            actorType: 'blabla'
+          }
+        })
+      })
+
+      it('Should fail succeed with the correct params', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          statusCodeExpected: 200,
+          query: {
+            state: 'accepted',
+            actorType: 'Application'
+          }
+        })
+      })
     })
 
     describe('When listing followers', function () {
@@ -142,6 +179,38 @@ describe('Test server follows API validators', function () {
       it('Should fail with an incorrect sort', async function () {
         await checkBadSortPagination(server.url, path)
       })
+
+      it('Should fail with an incorrect actor type', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          query: {
+            actorType: 'blabla'
+          }
+        })
+      })
+
+      it('Should fail with an incorrect state', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          query: {
+            state: 'blabla',
+            actorType: 'Application'
+          }
+        })
+      })
+
+      it('Should fail succeed with the correct params', async function () {
+        await makeGetRequest({
+          url: server.url,
+          path,
+          statusCodeExpected: 200,
+          query: {
+            state: 'accepted'
+          }
+        })
+      })
     })
 
     describe('When removing a follower', function () {
@@ -297,11 +366,6 @@ describe('Test server follows API validators', function () {
   })
 
   after(async function () {
-    killallServers([ server ])
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests([ server ])
   })
 })