]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
f05a1c30 | 2 | |
32b2b43c | 3 | import { expect } from 'chai' |
9fff08cf | 4 | import { pathExists, readdir } from 'fs-extra' |
f05a1c30 | 5 | import { join } from 'path' |
9fff08cf C |
6 | import { root } from '@server/helpers/core-utils' |
7 | import { ServerInfo } from '../server' | |
8 | ||
9 | async function expectAccountFollows (options: { | |
10 | server: ServerInfo | |
11 | handle: string | |
12 | followers: number | |
13 | following: number | |
14 | }) { | |
15 | const { server, handle, followers, following } = options | |
16 | ||
89d241a7 | 17 | const body = await server.accounts.list() |
9fff08cf C |
18 | const account = body.data.find(a => a.name + '@' + a.host === handle) |
19 | ||
20 | const message = `${handle} on ${server.url}` | |
21 | expect(account.followersCount).to.equal(followers, message) | |
22 | expect(account.followingCount).to.equal(following, message) | |
32b2b43c C |
23 | } |
24 | ||
57cfff78 | 25 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { |
f05a1c30 C |
26 | const testDirectory = 'test' + serverNumber |
27 | ||
28 | for (const directory of [ 'avatars' ]) { | |
29 | const directoryPath = join(root(), testDirectory, directory) | |
30 | ||
9fff08cf | 31 | const directoryExists = await pathExists(directoryPath) |
f05a1c30 C |
32 | expect(directoryExists).to.be.true |
33 | ||
62689b94 | 34 | const files = await readdir(directoryPath) |
f05a1c30 | 35 | for (const file of files) { |
57cfff78 | 36 | expect(file).to.not.contain(filename) |
f05a1c30 C |
37 | } |
38 | } | |
39 | } | |
40 | ||
265ba139 | 41 | export { |
32b2b43c | 42 | expectAccountFollows, |
9fff08cf | 43 | checkActorFilesWereRemoved |
265ba139 | 44 | } |