aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-29 19:07:05 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-29 19:07:05 +0100
commit7b1f49de22c40ae121ddb3c399b2540ba56fd414 (patch)
tree269e5dc7c2ebe4147319f1ee8e8b7f3c74549149 /server/tests/api/check-params.js
parent4ff0d86208dafbdd07beb6286fd93c795db8a95f (diff)
downloadPeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.tar.gz
PeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.tar.zst
PeerTube-7b1f49de22c40ae121ddb3c399b2540ba56fd414.zip
Server: add ability to update a video
Diffstat (limited to 'server/tests/api/check-params.js')
-rw-r--r--server/tests/api/check-params.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/server/tests/api/check-params.js b/server/tests/api/check-params.js
index 9aecc3720..e8f2aa821 100644
--- a/server/tests/api/check-params.js
+++ b/server/tests/api/check-params.js
@@ -10,6 +10,7 @@ const loginUtils = require('../utils/login')
10const requestsUtils = require('../utils/requests') 10const requestsUtils = require('../utils/requests')
11const serversUtils = require('../utils/servers') 11const serversUtils = require('../utils/servers')
12const usersUtils = require('../utils/users') 12const usersUtils = require('../utils/users')
13const videosUtils = require('../utils/videos')
13 14
14describe('Test parameters validator', function () { 15describe('Test parameters validator', function () {
15 let server = null 16 let server = null
@@ -439,6 +440,106 @@ describe('Test parameters validator', function () {
439 }) 440 })
440 }) 441 })
441 442
443 describe('When updating a video', function () {
444 let videoId
445
446 before(function (done) {
447 videosUtils.getVideosList(server.url, function (err, res) {
448 if (err) throw err
449
450 videoId = res.body.data[0].id
451
452 return done()
453 })
454 })
455
456 it('Should fail with nothing', function (done) {
457 const data = {}
458 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
459 })
460
461 it('Should fail without a valid uuid', function (done) {
462 const data = {
463 description: 'my super description',
464 tags: [ 'tag1', 'tag2' ]
465 }
466 requestsUtils.makePutBodyRequest(server.url, path + 'blabla', server.accessToken, data, done)
467 })
468
469 it('Should fail with an unknown id', function (done) {
470 const data = {
471 description: 'my super description',
472 tags: [ 'tag1', 'tag2' ]
473 }
474 requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06', server.accessToken, data, done)
475 })
476
477 it('Should fail with a long name', function (done) {
478 const data = {
479 name: 'My very very very very very very very very very very very very very very very very long name',
480 description: 'my super description',
481 tags: [ 'tag1', 'tag2' ]
482 }
483 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
484 })
485
486 it('Should fail with a long description', function (done) {
487 const data = {
488 name: 'my super name',
489 description: 'my super description which is very very very very very very very very very very very very very very' +
490 'very very very very very very very very very very very very very very very very very very very very very' +
491 'very very very very very very very very very very very very very very very long',
492 tags: [ 'tag1', 'tag2' ]
493 }
494 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
495 })
496
497 it('Should fail with too many tags', function (done) {
498 const data = {
499 name: 'my super name',
500 description: 'my super description',
501 tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
502 }
503 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
504 })
505
506 it('Should fail with not enough tags', function (done) {
507 const data = {
508 name: 'my super name',
509 description: 'my super description',
510 tags: [ ]
511 }
512 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
513 })
514
515 it('Should fail with a tag length too low', function (done) {
516 const data = {
517 name: 'my super name',
518 description: 'my super description',
519 tags: [ 'tag1', 't' ]
520 }
521 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
522 })
523
524 it('Should fail with a tag length too big', function (done) {
525 const data = {
526 name: 'my super name',
527 description: 'my super description',
528 tags: [ 'mysupertagtoolong', 'tag1' ]
529 }
530 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
531 })
532
533 it('Should fail with malformed tags', function (done) {
534 const data = {
535 name: 'my super name',
536 description: 'my super description',
537 tags: [ 'my tag' ]
538 }
539 requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
540 })
541 })
542
442 describe('When getting a video', function () { 543 describe('When getting a video', function () {
443 it('Should return the list of the videos with nothing', function (done) { 544 it('Should return the list of the videos with nothing', function (done) {
444 request(server.url) 545 request(server.url)