aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-16 22:31:45 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-16 22:31:45 +0200
commit5c39adb7313e0696aabb4b71196ab7b0b378c359 (patch)
treeac44b67890509338b984f8cbf11660dc77cdd0fd /server/tests/api/users.js
parent089ff2f2046fdbaf9531726eea1f8c6726ebf0c0 (diff)
downloadPeerTube-5c39adb7313e0696aabb4b71196ab7b0b378c359.tar.gz
PeerTube-5c39adb7313e0696aabb4b71196ab7b0b378c359.tar.zst
PeerTube-5c39adb7313e0696aabb4b71196ab7b0b378c359.zip
Server: add user list sort/pagination
Diffstat (limited to 'server/tests/api/users.js')
-rw-r--r--server/tests/api/users.js83
1 files changed, 79 insertions, 4 deletions
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index a2557d2ab..c6c892bf2 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -209,17 +209,92 @@ describe('Test users', function () {
209 usersUtils.getUsersList(server.url, function (err, res) { 209 usersUtils.getUsersList(server.url, function (err, res) {
210 if (err) throw err 210 if (err) throw err
211 211
212 const users = res.body.data 212 const result = res.body
213 const total = result.total
214 const users = result.data
213 215
216 expect(total).to.equal(2)
214 expect(users).to.be.an('array') 217 expect(users).to.be.an('array')
215 expect(users.length).to.equal(2) 218 expect(users.length).to.equal(2)
216 219
217 const rootUser = users[0] 220 const user = users[0]
221 expect(user.username).to.equal('user_1')
222
223 const rootUser = users[1]
218 expect(rootUser.username).to.equal('root') 224 expect(rootUser.username).to.equal('root')
225 userId = user.id
226
227 done()
228 })
229 })
230
231 it('Should list only the first user by username asc', function (done) {
232 usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, 'username', function (err, res) {
233 if (err) throw err
234
235 const result = res.body
236 const total = result.total
237 const users = result.data
238
239 expect(total).to.equal(2)
240 expect(users.length).to.equal(1)
219 241
220 const user = users[1] 242 const user = users[0]
243 expect(user.username).to.equal('root')
244
245 done()
246 })
247 })
248
249 it('Should list only the first user by username desc', function (done) {
250 usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-username', function (err, res) {
251 if (err) throw err
252
253 const result = res.body
254 const total = result.total
255 const users = result.data
256
257 expect(total).to.equal(2)
258 expect(users.length).to.equal(1)
259
260 const user = users[0]
221 expect(user.username).to.equal('user_1') 261 expect(user.username).to.equal('user_1')
222 userId = user.id 262
263 done()
264 })
265 })
266
267 it('Should list only the second user by createdDate desc', function (done) {
268 usersUtils.getUsersListPaginationAndSort(server.url, 0, 1, '-createdDate', function (err, res) {
269 if (err) throw err
270
271 const result = res.body
272 const total = result.total
273 const users = result.data
274
275 expect(total).to.equal(2)
276 expect(users.length).to.equal(1)
277
278 const user = users[0]
279 expect(user.username).to.equal('user_1')
280
281 done()
282 })
283 })
284
285 it('Should list all the users by createdDate asc', function (done) {
286 usersUtils.getUsersListPaginationAndSort(server.url, 0, 2, 'createdDate', function (err, res) {
287 if (err) throw err
288
289 const result = res.body
290 const total = result.total
291 const users = result.data
292
293 expect(total).to.equal(2)
294 expect(users.length).to.equal(2)
295
296 expect(users[0].username).to.equal('root')
297 expect(users[1].username).to.equal('user_1')
223 298
224 done() 299 done()
225 }) 300 })