From 9639bd175726b73f8fe664b5ced12a72407b1f0b Mon Sep 17 00:00:00 2001 From: buoyantair Date: Mon, 29 Oct 2018 22:18:31 +0530 Subject: Move utils to /shared Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336 --- server/tests/utils/users/accounts.ts | 63 ------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 server/tests/utils/users/accounts.ts (limited to 'server/tests/utils/users/accounts.ts') diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.ts deleted file mode 100644 index f82b8d906..000000000 --- a/server/tests/utils/users/accounts.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* tslint:disable:no-unused-expression */ - -import { expect } from 'chai' -import { existsSync, readdir } from 'fs-extra' -import { join } from 'path' -import { Account } from '../../../../shared/models/actors' -import { root } from '../index' -import { makeGetRequest } from '../requests/requests' - -function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) { - const path = '/api/v1/accounts' - - return makeGetRequest({ - url, - query: { sort }, - path, - statusCodeExpected - }) -} - -function getAccount (url: string, accountName: string, statusCodeExpected = 200) { - const path = '/api/v1/accounts/' + accountName - - return makeGetRequest({ - url, - path, - statusCodeExpected - }) -} - -async function expectAccountFollows (url: string, nameWithDomain: string, followersCount: number, followingCount: number) { - const res = await getAccountsList(url) - const account = res.body.data.find((a: Account) => a.name + '@' + a.host === nameWithDomain) - - const message = `${nameWithDomain} on ${url}` - expect(account.followersCount).to.equal(followersCount, message) - expect(account.followingCount).to.equal(followingCount, message) -} - -async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { - const testDirectory = 'test' + serverNumber - - for (const directory of [ 'avatars' ]) { - const directoryPath = join(root(), testDirectory, directory) - - const directoryExists = existsSync(directoryPath) - expect(directoryExists).to.be.true - - const files = await readdir(directoryPath) - for (const file of files) { - expect(file).to.not.contain(actorUUID) - } - } -} - -// --------------------------------------------------------------------------- - -export { - getAccount, - expectAccountFollows, - getAccountsList, - checkActorFilesWereRemoved -} -- cgit v1.2.3