diff options
Diffstat (limited to 'server/tests/utils/users.js')
-rw-r--r-- | server/tests/utils/users.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/server/tests/utils/users.js b/server/tests/utils/users.js index 8138074d0..310dc0c6b 100644 --- a/server/tests/utils/users.js +++ b/server/tests/utils/users.js | |||
@@ -4,6 +4,7 @@ const request = require('supertest') | |||
4 | 4 | ||
5 | const usersUtils = { | 5 | const usersUtils = { |
6 | createUser, | 6 | createUser, |
7 | registerUser, | ||
7 | getUserInformation, | 8 | getUserInformation, |
8 | getUserVideoRating, | 9 | getUserVideoRating, |
9 | getUsersList, | 10 | getUsersList, |
@@ -36,6 +37,27 @@ function createUser (url, accessToken, username, password, specialStatus, end) { | |||
36 | .end(end) | 37 | .end(end) |
37 | } | 38 | } |
38 | 39 | ||
40 | function registerUser (url, username, password, specialStatus, end) { | ||
41 | if (!end) { | ||
42 | end = specialStatus | ||
43 | specialStatus = 204 | ||
44 | } | ||
45 | |||
46 | const path = '/api/v1/users/register' | ||
47 | const body = { | ||
48 | username, | ||
49 | password, | ||
50 | email: username + '@example.com' | ||
51 | } | ||
52 | |||
53 | request(url) | ||
54 | .post(path) | ||
55 | .set('Accept', 'application/json') | ||
56 | .send(body) | ||
57 | .expect(specialStatus) | ||
58 | .end(end) | ||
59 | } | ||
60 | |||
39 | function getUserInformation (url, accessToken, end) { | 61 | function getUserInformation (url, accessToken, end) { |
40 | const path = '/api/v1/users/me' | 62 | const path = '/api/v1/users/me' |
41 | 63 | ||