aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/users.js13
-rw-r--r--server/tests/utils/videos.js20
2 files changed, 32 insertions, 1 deletions
diff --git a/server/tests/utils/users.js b/server/tests/utils/users.js
index a2c010f64..7817160b9 100644
--- a/server/tests/utils/users.js
+++ b/server/tests/utils/users.js
@@ -5,6 +5,7 @@ const request = require('supertest')
5const usersUtils = { 5const usersUtils = {
6 createUser, 6 createUser,
7 getUserInformation, 7 getUserInformation,
8 getUserVideoRating,
8 getUsersList, 9 getUsersList,
9 getUsersListPaginationAndSort, 10 getUsersListPaginationAndSort,
10 removeUser, 11 removeUser,
@@ -47,6 +48,18 @@ function getUserInformation (url, accessToken, end) {
47 .end(end) 48 .end(end)
48} 49}
49 50
51function getUserVideoRating (url, accessToken, videoId, end) {
52 const path = '/api/v1/users/me/videos/' + videoId + '/rating'
53
54 request(url)
55 .get(path)
56 .set('Accept', 'application/json')
57 .set('Authorization', 'Bearer ' + accessToken)
58 .expect(200)
59 .expect('Content-Type', /json/)
60 .end(end)
61}
62
50function getUsersList (url, end) { 63function getUsersList (url, end) {
51 const path = '/api/v1/users' 64 const path = '/api/v1/users'
52 65
diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js
index f94368437..177426076 100644
--- a/server/tests/utils/videos.js
+++ b/server/tests/utils/videos.js
@@ -16,7 +16,8 @@ const videosUtils = {
16 searchVideoWithSort, 16 searchVideoWithSort,
17 testVideoImage, 17 testVideoImage,
18 uploadVideo, 18 uploadVideo,
19 updateVideo 19 updateVideo,
20 rateVideo
20} 21}
21 22
22// ---------------------- Export functions -------------------- 23// ---------------------- Export functions --------------------
@@ -236,6 +237,23 @@ function updateVideo (url, accessToken, id, name, description, tags, specialStat
236 req.expect(specialStatus).end(end) 237 req.expect(specialStatus).end(end)
237} 238}
238 239
240function rateVideo (url, accessToken, id, rating, specialStatus, end) {
241 if (!end) {
242 end = specialStatus
243 specialStatus = 204
244 }
245
246 const path = '/api/v1/videos/' + id + '/rate'
247
248 request(url)
249 .put(path)
250 .set('Accept', 'application/json')
251 .set('Authorization', 'Bearer ' + accessToken)
252 .send({ rating })
253 .expect(specialStatus)
254 .end(end)
255}
256
239// --------------------------------------------------------------------------- 257// ---------------------------------------------------------------------------
240 258
241module.exports = videosUtils 259module.exports = videosUtils