From c5d31dba56d669c0df0209761c43c5a6ac7cec4a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Dec 2017 13:59:22 +0100 Subject: Tests directories refractor --- server/tests/utils/follows.ts | 77 ------------------------------------------- 1 file changed, 77 deletions(-) delete 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 deleted file mode 100644 index a9f798bcb..000000000 --- a/server/tests/utils/follows.ts +++ /dev/null @@ -1,77 +0,0 @@ -import * as request from 'supertest' -import { wait } from './miscs' -import { ServerInfo } from './servers' - -function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { - const path = '/api/v1/server/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/server/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/server/following' - - const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) - const res = await request(follower) - .post(path) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + accessToken) - .send({ 'hosts': followingHosts }) - .expect(expectedStatus) - - return res -} - -async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) { - const path = '/api/v1/server/following/' + target.host - - const res = await request(url) - .delete(path) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + accessToken) - .expect(expectedStatus) - - return res -} - -async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { - await Promise.all([ - follow(server1.url, [ server2.url ], server1.accessToken), - follow(server2.url, [ server1.url ], server2.accessToken) - ]) - - // Wait request propagation - await wait(10000) - - return true -} - -// --------------------------------------------------------------------------- - -export { - getFollowersListPaginationAndSort, - getFollowingListPaginationAndSort, - unfollow, - follow, - doubleFollow -} -- cgit v1.2.3