From ac81d1a06d57b9ae86663831e7f5edcef57b0fa4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Feb 2018 18:17:05 +0100 Subject: Add ability to set video thumbnail/preview --- server/tests/utils/requests/requests.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'server/tests/utils/requests') diff --git a/server/tests/utils/requests/requests.ts b/server/tests/utils/requests/requests.ts index 840072430..a9b1dff9a 100644 --- a/server/tests/utils/requests/requests.ts +++ b/server/tests/utils/requests/requests.ts @@ -1,4 +1,5 @@ import * as request from 'supertest' +import { buildAbsoluteFixturePath } from '../' function makeGetRequest (options: { url: string, @@ -40,8 +41,9 @@ function makeDeleteRequest (options: { .expect(options.statusCodeExpected) } -function makePostUploadRequest (options: { +function makeUploadRequest (options: { url: string, + method?: 'POST' | 'PUT', path: string, token: string, fields: { [ fieldName: string ]: any }, @@ -50,9 +52,14 @@ function makePostUploadRequest (options: { }) { if (!options.statusCodeExpected) options.statusCodeExpected = 400 - const req = request(options.url) - .post(options.path) - .set('Accept', 'application/json') + let req: request.Test + if (options.method === 'PUT') { + req = request(options.url).put(options.path) + } else { + req = request(options.url).post(options.path) + } + + req.set('Accept', 'application/json') if (options.token) req.set('Authorization', 'Bearer ' + options.token) @@ -70,7 +77,7 @@ function makePostUploadRequest (options: { Object.keys(options.attaches).forEach(attach => { const value = options.attaches[attach] - req.attach(attach, value) + req.attach(attach, buildAbsoluteFixturePath(value)) }) return req.expect(options.statusCodeExpected) @@ -119,7 +126,7 @@ function makePutBodyRequest (options: { export { makeGetRequest, - makePostUploadRequest, + makeUploadRequest, makePostBodyRequest, makePutBodyRequest, makeDeleteRequest -- cgit v1.2.3