From 4610bc5b12eaa4bfd64fe3fd70c65e5b722aa22d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Nov 2017 17:16:42 +0100 Subject: ApplicationFollow -> SeverFollow --- server/tests/utils/follows.ts | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 server/tests/utils/follows.ts (limited to 'server/tests/utils/follows.ts') diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts new file mode 100644 index 000000000..9ad1ca7f4 --- /dev/null +++ b/server/tests/utils/follows.ts @@ -0,0 +1,53 @@ +import * as request from 'supertest' + +import { wait } from './miscs' + +function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { + const path = '/api/v1/servers/followers' + + return request(url) + .get(path) + .query({ start }) + .query({ count }) + .query({ sort }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) +} + +function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) { + const path = '/api/v1/servers/following' + + return request(url) + .get(path) + .query({ start }) + .query({ count }) + .query({ sort }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) +} + +async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { + const path = '/api/v1/servers/follow' + + const res = await request(follower) + .post(path) + .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) + .send({ 'hosts': following }) + .expect(expectedStatus) + + // Wait request propagation + await wait(1000) + + return res +} + +// --------------------------------------------------------------------------- + +export { + getFollowersListPaginationAndSort, + getFollowingListPaginationAndSort, + follow +} -- cgit v1.2.3