]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/requests/check-api-params.ts
Optimize torrent URL update
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / requests / check-api-params.ts
index a2a549682aac9bd5f1646f8a69cfa85fc3475269..26ba1e9132eb6ec783d6e61ad5b59832e85ffd8b 100644 (file)
@@ -1,23 +1,31 @@
+import { HttpStatusCode } from '@shared/models'
 import { makeGetRequest } from './requests'
-import { immutableAssign } from '../miscs/miscs'
 
 function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
   return makeGetRequest({
     url,
     path,
     token,
-    query: immutableAssign(query, { start: 'hello' }),
-    statusCodeExpected: 400
+    query: { ...query, start: 'hello' },
+    expectedStatus: HttpStatusCode.BAD_REQUEST_400
   })
 }
 
-function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
-  return makeGetRequest({
+async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
+  await makeGetRequest({
+    url,
+    path,
+    token,
+    query: { ...query, count: 'hello' },
+    expectedStatus: HttpStatusCode.BAD_REQUEST_400
+  })
+
+  await makeGetRequest({
     url,
     path,
     token,
-    query: immutableAssign(query, { count: 'hello' }),
-    statusCodeExpected: 400
+    query: { ...query, count: 2000 },
+    expectedStatus: HttpStatusCode.BAD_REQUEST_400
   })
 }
 
@@ -26,8 +34,8 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer
     url,
     path,
     token,
-    query: immutableAssign(query, { sort: 'hello' }),
-    statusCodeExpected: 400
+    query: { ...query, sort: 'hello' },
+    expectedStatus: HttpStatusCode.BAD_REQUEST_400
   })
 }