aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/pods.js')
-rw-r--r--server/tests/utils/pods.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/server/tests/utils/pods.js b/server/tests/utils/pods.js
new file mode 100644
index 000000000..366492110
--- /dev/null
+++ b/server/tests/utils/pods.js
@@ -0,0 +1,70 @@
1'use strict'
2
3const request = require('supertest')
4
5const podsUtils = {
6 getFriendsList: getFriendsList,
7 makeFriends: makeFriends,
8 quitFriends: quitFriends
9}
10
11// ---------------------- Export functions --------------------
12
13function getFriendsList (url, end) {
14 const path = '/api/v1/pods/'
15
16 request(url)
17 .get(path)
18 .set('Accept', 'application/json')
19 .expect(200)
20 .expect('Content-Type', /json/)
21 .end(end)
22}
23
24function makeFriends (url, accessToken, expectedStatus, end) {
25 if (!end) {
26 end = expectedStatus
27 expectedStatus = 204
28 }
29
30 const path = '/api/v1/pods/makefriends'
31
32 // The first pod make friend with the third
33 request(url)
34 .get(path)
35 .set('Accept', 'application/json')
36 .set('Authorization', 'Bearer ' + accessToken)
37 .expect(expectedStatus)
38 .end(function (err, res) {
39 if (err) throw err
40
41 // Wait for the request between pods
42 setTimeout(end, 1000)
43 })
44}
45
46function quitFriends (url, accessToken, expectedStatus, end) {
47 if (!end) {
48 end = expectedStatus
49 expectedStatus = 204
50 }
51
52 const path = '/api/v1/pods/quitfriends'
53
54 // The first pod make friend with the third
55 request(url)
56 .get(path)
57 .set('Accept', 'application/json')
58 .set('Authorization', 'Bearer ' + accessToken)
59 .expect(expectedStatus)
60 .end(function (err, res) {
61 if (err) throw err
62
63 // Wait for the request between pods
64 setTimeout(end, 1000)
65 })
66}
67
68// ---------------------------------------------------------------------------
69
70module.exports = podsUtils