import * as request from 'supertest'
import { ServerInfo } from './servers'
import { waitJobs } from './jobs'
-import { makeGetRequest, makePostBodyRequest } from '..'
-
-function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
+import { makePostBodyRequest } from '../requests/requests'
+import { ActivityPubActorType, FollowState } from '@shared/models'
+
+function getFollowersListPaginationAndSort (options: {
+ url: string
+ start: number
+ count: number
+ sort: string
+ search?: string
+ actorType?: ActivityPubActorType
+ state?: FollowState
+}) {
+ const { url, start, count, sort, search, state, actorType } = options
const path = '/api/v1/server/followers'
+ const query = {
+ start,
+ count,
+ sort,
+ search,
+ state,
+ actorType
+ }
+
return request(url)
.get(path)
- .query({ start })
- .query({ count })
- .query({ sort })
- .query({ search })
+ .query(query)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
})
}
-function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
+function getFollowingListPaginationAndSort (options: {
+ url: string
+ start: number
+ count: number
+ sort: string
+ search?: string
+ actorType?: ActivityPubActorType
+ state?: FollowState
+}) {
+ const { url, start, count, sort, search, state, actorType } = options
const path = '/api/v1/server/following'
+ const query = {
+ start,
+ count,
+ sort,
+ search,
+ state,
+ actorType
+ }
+
return request(url)
.get(path)
- .query({ start })
- .query({ count })
- .query({ sort })
- .query({ search })
+ .query(query)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
.post(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
- .send({ 'hosts': followingHosts })
+ .send({ hosts: followingHosts })
.expect(expectedStatus)
}