From 0f91ae62df8a37194fea84ce1efa9e733d9c1fd8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 Nov 2017 13:43:29 +0100 Subject: Add follow tests --- server/tests/utils/follows.ts | 13 +++++++++++++ server/tests/utils/index.ts | 1 - server/tests/utils/request-schedulers.ts | 20 -------------------- 3 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 server/tests/utils/request-schedulers.ts (limited to 'server/tests/utils') diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts index 618436b3c..b88776011 100644 --- a/server/tests/utils/follows.ts +++ b/server/tests/utils/follows.ts @@ -42,6 +42,18 @@ async function follow (follower: string, following: string[], accessToken: strin return res } +async function unfollow (url: string, accessToken: string, id: number, expectedStatus = 204) { + const path = '/api/v1/server/following/' + id + + 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), @@ -59,6 +71,7 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { export { getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, + unfollow, follow, doubleFollow } diff --git a/server/tests/utils/index.ts b/server/tests/utils/index.ts index fe6d3b041..4308fd49a 100644 --- a/server/tests/utils/index.ts +++ b/server/tests/utils/index.ts @@ -4,7 +4,6 @@ export * from './config' export * from './login' export * from './miscs' export * from './follows' -export * from './request-schedulers' export * from './requests' export * from './servers' export * from './services' diff --git a/server/tests/utils/request-schedulers.ts b/server/tests/utils/request-schedulers.ts deleted file mode 100644 index f100f6d99..000000000 --- a/server/tests/utils/request-schedulers.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as request from 'supertest' - -import { ServerInfo } from '../utils' - -function getRequestsStats (server: ServerInfo) { - const path = '/api/v1/request-schedulers/stats' - - return request(server.url) - .get(path) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + server.accessToken) - .expect(200) - .expect('Content-Type', /json/) -} - -// --------------------------------------------------------------------------- - -export { - getRequestsStats -} -- cgit v1.2.3