aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/users')
-rw-r--r--server/tests/utils/users/users.ts29
1 files changed, 27 insertions, 2 deletions
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 @@
1import { isAbsolute, join } from 'path'
1import * as request from 'supertest' 2import * as request from 'supertest'
2import { makePutBodyRequest } from '../' 3import { makePostUploadRequest, makePutBodyRequest } from '../'
3 4
4import { UserRole } from '../../../../shared/index' 5import { UserRole } from '../../../../shared/index'
5 6
@@ -137,6 +138,29 @@ function updateMyUser (options: {
137 }) 138 })
138} 139}
139 140
141function updateMyAvatar (options: {
142 url: string,
143 accessToken: string,
144 fixture: string
145}) {
146 const path = '/api/v1/users/me/avatar/pick'
147 let filePath = ''
148 if (isAbsolute(options.fixture)) {
149 filePath = options.fixture
150 } else {
151 filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture)
152 }
153
154 return makePostUploadRequest({
155 url: options.url,
156 path,
157 token: options.accessToken,
158 fields: {},
159 attaches: { avatarfile: filePath },
160 statusCodeExpected: 200
161 })
162}
163
140function updateUser (options: { 164function updateUser (options: {
141 url: string 165 url: string
142 userId: number, 166 userId: number,
@@ -173,5 +197,6 @@ export {
173 removeUser, 197 removeUser,
174 updateUser, 198 updateUser,
175 updateMyUser, 199 updateMyUser,
176 getUserInformation 200 getUserInformation,
201 updateMyAvatar
177} 202}