From d38b82810638b9f664c9016fac2684454c273a77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Mar 2017 21:35:43 +0100 Subject: Add like/dislike system for videos --- server/tests/api/check-params/videos.js | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'server/tests/api/check-params/videos.js') diff --git a/server/tests/api/check-params/videos.js b/server/tests/api/check-params/videos.js index f8549a95b..0f5f40b8e 100644 --- a/server/tests/api/check-params/videos.js +++ b/server/tests/api/check-params/videos.js @@ -420,6 +420,48 @@ describe('Test videos API validator', function () { it('Should succeed with the correct parameters') }) + describe('When rating a video', function () { + let videoId + + before(function (done) { + videosUtils.getVideosList(server.url, function (err, res) { + if (err) throw err + + videoId = res.body.data[0].id + + return done() + }) + }) + + it('Should fail without a valid uuid', function (done) { + const data = { + rating: 'like' + } + requestsUtils.makePutBodyRequest(server.url, path + 'blabla/rate', server.accessToken, data, done) + }) + + it('Should fail with an unknown id', function (done) { + const data = { + rating: 'like' + } + requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', server.accessToken, data, done, 404) + }) + + it('Should fail with a wrong rating', function (done) { + const data = { + rating: 'likes' + } + requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done) + }) + + it('Should succeed with the correct parameters', function (done) { + const data = { + rating: 'like' + } + requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done, 204) + }) + }) + describe('When removing a video', function () { it('Should have 404 with nothing', function (done) { request(server.url) -- cgit v1.2.3