+ it('Should update a video', function (done) {
+ const attributes = {
+ name: 'my super video updated',
+ category: 4,
+ licence: 2,
+ description: 'my super description updated',
+ tags: [ 'tagup1', 'tagup2' ]
+ }
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, done)
+ })
+
+ it('Should have the video updated', function (done) {
+ this.timeout(60000)
+
+ videosUtils.getVideo(server.url, videoId, function (err, res) {
+ if (err) throw err
+
+ const video = res.body
+
+ expect(video.name).to.equal('my super video updated')
+ expect(video.category).to.equal(4)
+ expect(video.categoryLabel).to.equal('Art')
+ expect(video.licence).to.equal(2)
+ expect(video.licenceLabel).to.equal('Attribution - Share Alike')
+ expect(video.description).to.equal('my super description updated')
+ expect(video.podHost).to.equal('localhost:9001')
+ expect(video.author).to.equal('root')
+ expect(video.isLocal).to.be.true
+ expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
+ expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+ videosUtils.testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath, function (err, test) {
+ if (err) throw err
+ expect(test).to.equal(true)
+
+ webtorrent.add(video.magnetUri, function (torrent) {
+ expect(torrent.files).to.exist
+ expect(torrent.files.length).to.equal(1)
+ expect(torrent.files[0].path).to.exist.and.to.not.equal('')
+
+ done()
+ })
+ })
+ })
+ })
+
+ it('Should update only the tags of a video', function (done) {
+ const attributes = {
+ tags: [ 'tag1', 'tag2', 'supertag' ]
+ }
+
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
+ if (err) throw err
+
+ videosUtils.getVideo(server.url, videoId, function (err, res) {
+ if (err) throw err
+
+ const video = res.body
+
+ expect(video.name).to.equal('my super video updated')
+ expect(video.category).to.equal(4)
+ expect(video.categoryLabel).to.equal('Art')
+ expect(video.licence).to.equal(2)
+ expect(video.licenceLabel).to.equal('Attribution - Share Alike')
+ expect(video.description).to.equal('my super description updated')
+ expect(video.podHost).to.equal('localhost:9001')
+ expect(video.author).to.equal('root')
+ expect(video.isLocal).to.be.true
+ expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
+ expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+ done()
+ })
+ })
+ })
+
+ it('Should update only the description of a video', function (done) {
+ const attributes = {
+ description: 'hello everybody'
+ }
+
+ videosUtils.updateVideo(server.url, server.accessToken, videoId, attributes, function (err) {
+ if (err) throw err
+
+ videosUtils.getVideo(server.url, videoId, function (err, res) {
+ if (err) throw err
+
+ const video = res.body
+
+ expect(video.name).to.equal('my super video updated')
+ expect(video.category).to.equal(4)
+ expect(video.categoryLabel).to.equal('Art')
+ expect(video.licence).to.equal(2)
+ expect(video.licenceLabel).to.equal('Attribution - Share Alike')
+ expect(video.description).to.equal('hello everybody')
+ expect(video.podHost).to.equal('localhost:9001')
+ expect(video.author).to.equal('root')
+ expect(video.isLocal).to.be.true
+ expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
+ expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
+
+ done()
+ })
+ })
+ })
+
+ it('Should like a video', function (done) {
+ videosUtils.rateVideo(server.url, server.accessToken, videoId, 'like', function (err) {
+ if (err) throw err
+
+ videosUtils.getVideo(server.url, videoId, function (err, res) {
+ if (err) throw err
+
+ const video = res.body
+
+ expect(video.likes).to.equal(1)
+ expect(video.dislikes).to.equal(0)
+
+ done()
+ })
+ })
+ })
+
+ it('Should dislike the same video', function (done) {
+ videosUtils.rateVideo(server.url, server.accessToken, videoId, 'dislike', function (err) {
+ if (err) throw err
+
+ videosUtils.getVideo(server.url, videoId, function (err, res) {
+ if (err) throw err
+
+ const video = res.body
+
+ expect(video.likes).to.equal(0)
+ expect(video.dislikes).to.equal(1)
+
+ done()
+ })
+ })
+ })
+