]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/users/accounts.ts
Add tests for emails
[github/Chocobozzz/PeerTube.git] / server / tests / utils / users / accounts.ts
index 0ec7992b3763372d0158a674d8722a660f20e60c..a5c13c319a7d11bda561d6ebe9c05e3b2dd494d6 100644 (file)
@@ -1,5 +1,11 @@
+/* tslint:disable:no-unused-expression */
+
 import { expect } from 'chai'
+import { existsSync } from 'fs'
+import { join } from 'path'
 import { Account } from '../../../../shared/models/actors'
+import { readdirPromise } from '../../../helpers/core-utils'
+import { root } from '../index'
 import { makeGetRequest } from '../requests/requests'
 
 function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) {
@@ -32,10 +38,27 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow
   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 readdirPromise(directoryPath)
+    for (const file of files) {
+      expect(file).to.not.contain(actorUUID)
+    }
+  }
+}
+
 // ---------------------------------------------------------------------------
 
 export {
   getAccount,
   expectAccountFollows,
-  getAccountsList
+  getAccountsList,
+  checkActorFilesWereRemoved
 }