]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/utils/users/accounts.ts
Set sort refractoring
[github/Chocobozzz/PeerTube.git] / server / tests / utils / users / accounts.ts
CommitLineData
32b2b43c
C
1import { expect } from 'chai'
2import { Account } from '../../../../shared/models/actors'
265ba139
C
3import { makeGetRequest } from '../requests/requests'
4
5function 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
16function 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
26async 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
37export {
38 getAccount,
32b2b43c 39 expectAccountFollows,
265ba139
C
40 getAccountsList
41}