3 const request
= require('supertest')
10 getUsersListPaginationAndSort
,
15 // ---------------------- Export functions --------------------
17 function createUser (url
, accessToken
, username
, password
, specialStatus
, end
) {
23 const path
= '/api/v1/users'
27 email: username
+ '@example.com'
32 .set('Accept', 'application/json')
33 .set('Authorization', 'Bearer ' + accessToken
)
35 .expect(specialStatus
)
39 function getUserInformation (url
, accessToken
, end
) {
40 const path
= '/api/v1/users/me'
44 .set('Accept', 'application/json')
45 .set('Authorization', 'Bearer ' + accessToken
)
47 .expect('Content-Type', /json/)
51 function getUserVideoRating (url
, accessToken
, videoId
, end
) {
52 const path
= '/api/v1/users/me/videos/' + videoId
+ '/rating'
56 .set('Accept', 'application/json')
57 .set('Authorization', 'Bearer ' + accessToken
)
59 .expect('Content-Type', /json/)
63 function getUsersList (url
, end
) {
64 const path
= '/api/v1/users'
68 .set('Accept', 'application/json')
70 .expect('Content-Type', /json/)
74 function getUsersListPaginationAndSort (url
, start
, count
, sort
, end
) {
75 const path
= '/api/v1/users'
79 .query({ start: start
})
80 .query({ count: count
})
81 .query({ sort: sort
})
82 .set('Accept', 'application/json')
84 .expect('Content-Type', /json/)
88 function removeUser (url
, userId
, accessToken
, expectedStatus
, end
) {
94 const path
= '/api/v1/users'
97 .delete(path
+ '/' + userId
)
98 .set('Accept', 'application/json')
99 .set('Authorization', 'Bearer ' + accessToken
)
100 .expect(expectedStatus
)
104 function updateUser (url
, userId
, accessToken
, newPassword
, end
) {
105 const path
= '/api/v1/users/' + userId
109 .set('Accept', 'application/json')
110 .set('Authorization', 'Bearer ' + accessToken
)
111 .send({ password: newPassword
})
116 // ---------------------------------------------------------------------------
118 module
.exports
= usersUtils