From c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Dec 2017 19:10:13 +0100 Subject: Begin to add avatar to actors --- server/tests/utils/users/users.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'server/tests/utils/users/users.ts') diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index e0cca3f51..90b1ca0a6 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts @@ -1,5 +1,6 @@ +import { isAbsolute, join } from 'path' import * as request from 'supertest' -import { makePutBodyRequest } from '../' +import { makePostUploadRequest, makePutBodyRequest } from '../' import { UserRole } from '../../../../shared/index' @@ -137,6 +138,29 @@ function updateMyUser (options: { }) } +function updateMyAvatar (options: { + url: string, + accessToken: string, + fixture: string +}) { + const path = '/api/v1/users/me/avatar/pick' + let filePath = '' + if (isAbsolute(options.fixture)) { + filePath = options.fixture + } else { + filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture) + } + + return makePostUploadRequest({ + url: options.url, + path, + token: options.accessToken, + fields: {}, + attaches: { avatarfile: filePath }, + statusCodeExpected: 200 + }) +} + function updateUser (options: { url: string userId: number, @@ -173,5 +197,6 @@ export { removeUser, updateUser, updateMyUser, - getUserInformation + getUserInformation, + updateMyAvatar } -- cgit v1.2.3