diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-03-16 22:29:27 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-03-16 22:29:27 +0100 |
commit | f0f5567b6918fc60c8cab15e13aec03a89a91dfb (patch) | |
tree | 99dfdb9fa8273c9cda1360fd3b6bfccc515bf8be /server/tests/api/checkParams.js | |
parent | 5101105ef91bfe478f97546b78b321882da2079c (diff) | |
download | PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.gz PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.zst PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.zip |
Use const/let now we use node 4.2
Diffstat (limited to 'server/tests/api/checkParams.js')
-rw-r--r-- | server/tests/api/checkParams.js | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js index 01b620873..b31b0e894 100644 --- a/server/tests/api/checkParams.js +++ b/server/tests/api/checkParams.js | |||
@@ -1,27 +1,27 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | var async = require('async') | 3 | const async = require('async') |
4 | var chai = require('chai') | 4 | const chai = require('chai') |
5 | var expect = chai.expect | 5 | const expect = chai.expect |
6 | var pathUtils = require('path') | 6 | const pathUtils = require('path') |
7 | var request = require('supertest') | 7 | const request = require('supertest') |
8 | 8 | ||
9 | var utils = require('./utils') | 9 | const utils = require('./utils') |
10 | 10 | ||
11 | describe('Test parameters validator', function () { | 11 | describe('Test parameters validator', function () { |
12 | var app = null | 12 | let app = null |
13 | var url = '' | 13 | let url = '' |
14 | 14 | ||
15 | function makePostRequest (path, fields, attach, done, fail) { | 15 | function makePostRequest (path, fields, attach, done, fail) { |
16 | var status_code = 400 | 16 | let status_code = 400 |
17 | if (fail !== undefined && fail === false) status_code = 200 | 17 | if (fail !== undefined && fail === false) status_code = 200 |
18 | 18 | ||
19 | var req = request(url) | 19 | const req = request(url) |
20 | .post(path) | 20 | .post(path) |
21 | .set('Accept', 'application/json') | 21 | .set('Accept', 'application/json') |
22 | 22 | ||
23 | Object.keys(fields).forEach(function (field) { | 23 | Object.keys(fields).forEach(function (field) { |
24 | var value = fields[field] | 24 | const value = fields[field] |
25 | req.field(field, value) | 25 | req.field(field, value) |
26 | }) | 26 | }) |
27 | 27 | ||
@@ -29,7 +29,7 @@ describe('Test parameters validator', function () { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | function makePostBodyRequest (path, fields, done, fail) { | 31 | function makePostBodyRequest (path, fields, done, fail) { |
32 | var status_code = 400 | 32 | let status_code = 400 |
33 | if (fail !== undefined && fail === false) status_code = 200 | 33 | if (fail !== undefined && fail === false) status_code = 200 |
34 | 34 | ||
35 | request(url) | 35 | request(url) |
@@ -59,16 +59,16 @@ describe('Test parameters validator', function () { | |||
59 | }) | 59 | }) |
60 | 60 | ||
61 | describe('Of the pods API', function () { | 61 | describe('Of the pods API', function () { |
62 | var path = '/api/v1/pods/' | 62 | const path = '/api/v1/pods/' |
63 | 63 | ||
64 | describe('When adding a pod', function () { | 64 | describe('When adding a pod', function () { |
65 | it('Should fail with nothing', function (done) { | 65 | it('Should fail with nothing', function (done) { |
66 | var data = {} | 66 | const data = {} |
67 | makePostBodyRequest(path, data, done) | 67 | makePostBodyRequest(path, data, done) |
68 | }) | 68 | }) |
69 | 69 | ||
70 | it('Should fail without public key', function (done) { | 70 | it('Should fail without public key', function (done) { |
71 | var data = { | 71 | const data = { |
72 | data: { | 72 | data: { |
73 | url: 'http://coucou.com' | 73 | url: 'http://coucou.com' |
74 | } | 74 | } |
@@ -77,7 +77,7 @@ describe('Test parameters validator', function () { | |||
77 | }) | 77 | }) |
78 | 78 | ||
79 | it('Should fail without an url', function (done) { | 79 | it('Should fail without an url', function (done) { |
80 | var data = { | 80 | const data = { |
81 | data: { | 81 | data: { |
82 | publicKey: 'mysuperpublickey' | 82 | publicKey: 'mysuperpublickey' |
83 | } | 83 | } |
@@ -86,7 +86,7 @@ describe('Test parameters validator', function () { | |||
86 | }) | 86 | }) |
87 | 87 | ||
88 | it('Should fail with an incorrect url', function (done) { | 88 | it('Should fail with an incorrect url', function (done) { |
89 | var data = { | 89 | const data = { |
90 | data: { | 90 | data: { |
91 | url: 'coucou.com', | 91 | url: 'coucou.com', |
92 | publicKey: 'mysuperpublickey' | 92 | publicKey: 'mysuperpublickey' |
@@ -102,7 +102,7 @@ describe('Test parameters validator', function () { | |||
102 | }) | 102 | }) |
103 | 103 | ||
104 | it('Should succeed with the correct parameters', function (done) { | 104 | it('Should succeed with the correct parameters', function (done) { |
105 | var data = { | 105 | const data = { |
106 | data: { | 106 | data: { |
107 | url: 'http://coucou.com', | 107 | url: 'http://coucou.com', |
108 | publicKey: 'mysuperpublickey' | 108 | publicKey: 'mysuperpublickey' |
@@ -114,7 +114,7 @@ describe('Test parameters validator', function () { | |||
114 | }) | 114 | }) |
115 | 115 | ||
116 | describe('Of the videos API', function () { | 116 | describe('Of the videos API', function () { |
117 | var path = '/api/v1/videos/' | 117 | const path = '/api/v1/videos/' |
118 | 118 | ||
119 | describe('When searching a video', function () { | 119 | describe('When searching a video', function () { |
120 | it('Should fail with nothing', function (done) { | 120 | it('Should fail with nothing', function (done) { |
@@ -127,81 +127,81 @@ describe('Test parameters validator', function () { | |||
127 | 127 | ||
128 | describe('When adding a video', function () { | 128 | describe('When adding a video', function () { |
129 | it('Should fail with nothing', function (done) { | 129 | it('Should fail with nothing', function (done) { |
130 | var data = {} | 130 | const data = {} |
131 | var attach = {} | 131 | const attach = {} |
132 | makePostRequest(path, data, attach, done) | 132 | makePostRequest(path, data, attach, done) |
133 | }) | 133 | }) |
134 | 134 | ||
135 | it('Should fail without name', function (done) { | 135 | it('Should fail without name', function (done) { |
136 | var data = { | 136 | const data = { |
137 | description: 'my super description' | 137 | description: 'my super description' |
138 | } | 138 | } |
139 | var attach = { | 139 | const attach = { |
140 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') | 140 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') |
141 | } | 141 | } |
142 | makePostRequest(path, data, attach, done) | 142 | makePostRequest(path, data, attach, done) |
143 | }) | 143 | }) |
144 | 144 | ||
145 | it('Should fail with a long name', function (done) { | 145 | it('Should fail with a long name', function (done) { |
146 | var data = { | 146 | const data = { |
147 | name: 'My very very very very very very very very very very very very very very very very long name', | 147 | name: 'My very very very very very very very very very very very very very very very very long name', |
148 | description: 'my super description' | 148 | description: 'my super description' |
149 | } | 149 | } |
150 | var attach = { | 150 | const attach = { |
151 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') | 151 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') |
152 | } | 152 | } |
153 | makePostRequest(path, data, attach, done) | 153 | makePostRequest(path, data, attach, done) |
154 | }) | 154 | }) |
155 | 155 | ||
156 | it('Should fail without description', function (done) { | 156 | it('Should fail without description', function (done) { |
157 | var data = { | 157 | const data = { |
158 | name: 'my super name' | 158 | name: 'my super name' |
159 | } | 159 | } |
160 | var attach = { | 160 | const attach = { |
161 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') | 161 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') |
162 | } | 162 | } |
163 | makePostRequest(path, data, attach, done) | 163 | makePostRequest(path, data, attach, done) |
164 | }) | 164 | }) |
165 | 165 | ||
166 | it('Should fail with a long description', function (done) { | 166 | it('Should fail with a long description', function (done) { |
167 | var data = { | 167 | const data = { |
168 | name: 'my super name', | 168 | name: 'my super name', |
169 | description: 'my super description which is very very very very very very very very very very very very very very' + | 169 | description: 'my super description which is very very very very very very very very very very very very very very' + |
170 | 'very very very very very very very very very very very very very very very very very very very very very' + | 170 | 'very very very very very very very very very very very very very very very very very very very very very' + |
171 | 'very very very very very very very very very very very very very very very long' | 171 | 'very very very very very very very very very very very very very very very long' |
172 | } | 172 | } |
173 | var attach = { | 173 | const attach = { |
174 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') | 174 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') |
175 | } | 175 | } |
176 | makePostRequest(path, data, attach, done) | 176 | makePostRequest(path, data, attach, done) |
177 | }) | 177 | }) |
178 | 178 | ||
179 | it('Should fail without an input file', function (done) { | 179 | it('Should fail without an input file', function (done) { |
180 | var data = { | 180 | const data = { |
181 | name: 'my super name', | 181 | name: 'my super name', |
182 | description: 'my super description' | 182 | description: 'my super description' |
183 | } | 183 | } |
184 | var attach = {} | 184 | const attach = {} |
185 | makePostRequest(path, data, attach, done) | 185 | makePostRequest(path, data, attach, done) |
186 | }) | 186 | }) |
187 | 187 | ||
188 | it('Should fail without an incorrect input file', function (done) { | 188 | it('Should fail without an incorrect input file', function (done) { |
189 | var data = { | 189 | const data = { |
190 | name: 'my super name', | 190 | name: 'my super name', |
191 | description: 'my super description' | 191 | description: 'my super description' |
192 | } | 192 | } |
193 | var attach = { | 193 | const attach = { |
194 | 'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | 194 | 'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm') |
195 | } | 195 | } |
196 | makePostRequest(path, data, attach, done) | 196 | makePostRequest(path, data, attach, done) |
197 | }) | 197 | }) |
198 | 198 | ||
199 | it('Should succeed with the correct parameters', function (done) { | 199 | it('Should succeed with the correct parameters', function (done) { |
200 | var data = { | 200 | const data = { |
201 | name: 'my super name', | 201 | name: 'my super name', |
202 | description: 'my super description' | 202 | description: 'my super description' |
203 | } | 203 | } |
204 | var attach = { | 204 | const attach = { |
205 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') | 205 | 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm') |
206 | } | 206 | } |
207 | makePostRequest(path, data, attach, function () { | 207 | makePostRequest(path, data, attach, function () { |