]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/utils.js
Extends the search feature by customizing the search field (name,
[github/Chocobozzz/PeerTube.git] / server / tests / api / utils.js
index 218b461579b8280232fae06fbb86d8f63016e403..c6430c930612cd020b3f1e5f57f0a7bf1db7e941 100644 (file)
@@ -291,24 +291,31 @@ function runServer (number, callback) {
   })
 }
 
-function searchVideo (url, search, end) {
-  const path = '/api/v1/videos'
+function searchVideo (url, search, field, end) {
+  if (!end) {
+    end = field
+    field = null
+  }
 
-  request(url)
-    .get(path + '/search/' + search)
-    .set('Accept', 'application/json')
-    .expect(200)
-    .expect('Content-Type', /json/)
-    .end(end)
+  const path = '/api/v1/videos'
+  const req = request(url)
+              .get(path + '/search/' + search)
+              .set('Accept', 'application/json')
+
+  if (field) req.query({ field: field })
+  req.expect(200)
+     .expect('Content-Type', /json/)
+     .end(end)
 }
 
-function searchVideoWithPagination (url, search, start, count, end) {
+function searchVideoWithPagination (url, search, field, start, count, end) {
   const path = '/api/v1/videos'
 
   request(url)
     .get(path + '/search/' + search)
     .query({ start: start })
     .query({ count: count })
+    .query({ field: field })
     .set('Accept', 'application/json')
     .expect(200)
     .expect('Content-Type', /json/)