aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/pods.ts32
-rw-r--r--server/tests/api/friends-basic.ts19
2 files changed, 48 insertions, 3 deletions
diff --git a/server/tests/api/check-params/pods.ts b/server/tests/api/check-params/pods.ts
index a897e4dcd..9f9c2e4f0 100644
--- a/server/tests/api/check-params/pods.ts
+++ b/server/tests/api/check-params/pods.ts
@@ -15,7 +15,6 @@ import {
15} from '../../utils' 15} from '../../utils'
16 16
17describe('Test pods API validators', function () { 17describe('Test pods API validators', function () {
18 const path = '/api/v1/pods/'
19 let server: ServerInfo 18 let server: ServerInfo
20 19
21 // --------------------------------------------------------------- 20 // ---------------------------------------------------------------
@@ -30,6 +29,7 @@ describe('Test pods API validators', function () {
30 }) 29 })
31 30
32 describe('When managing friends', function () { 31 describe('When managing friends', function () {
32 const path = '/api/v1/pods/'
33 let userAccessToken = null 33 let userAccessToken = null
34 34
35 before(async function () { 35 before(async function () {
@@ -110,6 +110,32 @@ describe('Test pods API validators', function () {
110 }) 110 })
111 }) 111 })
112 112
113 describe('When listing friends', function () {
114 it('Should fail with a bad start pagination', async function () {
115 await request(server.url)
116 .get(path)
117 .query({ start: 'hello' })
118 .set('Accept', 'application/json')
119 .expect(400)
120 })
121
122 it('Should fail with a bad count pagination', async function () {
123 await request(server.url)
124 .get(path)
125 .query({ count: 'hello' })
126 .set('Accept', 'application/json')
127 .expect(400)
128 })
129
130 it('Should fail with an incorrect sort', async function () {
131 await request(server.url)
132 .get(path)
133 .query({ sort: 'hello' })
134 .set('Accept', 'application/json')
135 .expect(400)
136 })
137 })
138
113 describe('When quitting friends', function () { 139 describe('When quitting friends', function () {
114 it('Should fail with an invalid token', async function () { 140 it('Should fail with an invalid token', async function () {
115 await request(server.url) 141 await request(server.url)
@@ -175,7 +201,9 @@ describe('Test pods API validators', function () {
175 }) 201 })
176 }) 202 })
177 203
178 describe('When adding a pod', function () { 204 describe('When adding a pod from remote', function () {
205 const path = '/api/v1/remote/pods/add'
206
179 it('Should fail with nothing', async function () { 207 it('Should fail with nothing', async function () {
180 const fields = {} 208 const fields = {}
181 await makePostBodyRequest({ url: server.url, path, fields }) 209 await makePostBodyRequest({ url: server.url, path, fields })
diff --git a/server/tests/api/friends-basic.ts b/server/tests/api/friends-basic.ts
index 13edf6273..efca4fda2 100644
--- a/server/tests/api/friends-basic.ts
+++ b/server/tests/api/friends-basic.ts
@@ -15,7 +15,8 @@ import {
15 makeFriends, 15 makeFriends,
16 getFriendsList, 16 getFriendsList,
17 dateIsValid, 17 dateIsValid,
18 quitOneFriend 18 quitOneFriend,
19 getPodsListPaginationAndSort
19} from '../utils' 20} from '../utils'
20 21
21describe('Test basic friends', function () { 22describe('Test basic friends', function () {
@@ -120,6 +121,22 @@ describe('Test basic friends', function () {
120 await makeFriends(server.url, server.accessToken, 409) 121 await makeFriends(server.url, server.accessToken, 409)
121 }) 122 })
122 123
124 it('Should list friends correctly', async function () {
125 const start = 1
126 const count = 1
127 const sort = '-host'
128
129 const res = await getPodsListPaginationAndSort(servers[0].url, start, count, sort)
130 expect(res.body.total).to.equal(2)
131 expect(res.body.data).to.have.lengthOf(1)
132
133 const pod = res.body.data[0]
134 expect(pod.host).to.equal('localhost:9002')
135 expect(pod.email).to.equal('admin2@example.com')
136 expect(pod.score).to.equal(20)
137 expect(dateIsValid(pod.createdAt)).to.be.true
138 })
139
123 it('Should quit friends of pod 2', async function () { 140 it('Should quit friends of pod 2', async function () {
124 this.timeout(10000) 141 this.timeout(10000)
125 142