]>
Commit | Line | Data |
---|---|---|
32b2b43c C |
1 | import { expect } from 'chai' |
2 | import { Account } from '../../../../shared/models/actors' | |
265ba139 C |
3 | import { makeGetRequest } from '../requests/requests' |
4 | ||
5 | function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) { | |
6 | const path = '/api/v1/accounts' | |
7 | ||
8 | return makeGetRequest({ | |
9 | url, | |
10 | query: { sort }, | |
11 | path, | |
12 | statusCodeExpected | |
13 | }) | |
14 | } | |
15 | ||
16 | function getAccount (url: string, accountId: number | string, statusCodeExpected = 200) { | |
17 | const path = '/api/v1/accounts/' + accountId | |
18 | ||
19 | return makeGetRequest({ | |
20 | url, | |
21 | path, | |
22 | statusCodeExpected | |
23 | }) | |
24 | } | |
25 | ||
32b2b43c C |
26 | async function expectAccountFollows (url: string, nameWithDomain: string, followersCount: number, followingCount: number) { |
27 | const res = await getAccountsList(url) | |
28 | const account = res.body.data.find((a: Account) => a.name + '@' + a.host === nameWithDomain) | |
29 | ||
30 | const message = `${nameWithDomain} on ${url}` | |
31 | expect(account.followersCount).to.equal(followersCount, message) | |
32 | expect(account.followingCount).to.equal(followingCount, message) | |
33 | } | |
34 | ||
265ba139 C |
35 | // --------------------------------------------------------------------------- |
36 | ||
37 | export { | |
38 | getAccount, | |
32b2b43c | 39 | expectAccountFollows, |
265ba139 C |
40 | getAccountsList |
41 | } |