diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-13 18:17:05 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-14 16:03:09 +0100 |
commit | ac81d1a06d57b9ae86663831e7f5edcef57b0fa4 (patch) | |
tree | da31775c9533d3e270f68f921e146f086bf7c0b8 /server/tests/utils/requests/requests.ts | |
parent | e883399fa6caa56bb8519c9a2e22d88001f26661 (diff) | |
download | PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.gz PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.zst PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.zip |
Add ability to set video thumbnail/preview
Diffstat (limited to 'server/tests/utils/requests/requests.ts')
-rw-r--r-- | server/tests/utils/requests/requests.ts | 19 |
1 files changed, 13 insertions, 6 deletions
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 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { buildAbsoluteFixturePath } from '../' | ||
2 | 3 | ||
3 | function makeGetRequest (options: { | 4 | function makeGetRequest (options: { |
4 | url: string, | 5 | url: string, |
@@ -40,8 +41,9 @@ function makeDeleteRequest (options: { | |||
40 | .expect(options.statusCodeExpected) | 41 | .expect(options.statusCodeExpected) |
41 | } | 42 | } |
42 | 43 | ||
43 | function makePostUploadRequest (options: { | 44 | function makeUploadRequest (options: { |
44 | url: string, | 45 | url: string, |
46 | method?: 'POST' | 'PUT', | ||
45 | path: string, | 47 | path: string, |
46 | token: string, | 48 | token: string, |
47 | fields: { [ fieldName: string ]: any }, | 49 | fields: { [ fieldName: string ]: any }, |
@@ -50,9 +52,14 @@ function makePostUploadRequest (options: { | |||
50 | }) { | 52 | }) { |
51 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 53 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
52 | 54 | ||
53 | const req = request(options.url) | 55 | let req: request.Test |
54 | .post(options.path) | 56 | if (options.method === 'PUT') { |
55 | .set('Accept', 'application/json') | 57 | req = request(options.url).put(options.path) |
58 | } else { | ||
59 | req = request(options.url).post(options.path) | ||
60 | } | ||
61 | |||
62 | req.set('Accept', 'application/json') | ||
56 | 63 | ||
57 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 64 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) |
58 | 65 | ||
@@ -70,7 +77,7 @@ function makePostUploadRequest (options: { | |||
70 | 77 | ||
71 | Object.keys(options.attaches).forEach(attach => { | 78 | Object.keys(options.attaches).forEach(attach => { |
72 | const value = options.attaches[attach] | 79 | const value = options.attaches[attach] |
73 | req.attach(attach, value) | 80 | req.attach(attach, buildAbsoluteFixturePath(value)) |
74 | }) | 81 | }) |
75 | 82 | ||
76 | return req.expect(options.statusCodeExpected) | 83 | return req.expect(options.statusCodeExpected) |
@@ -119,7 +126,7 @@ function makePutBodyRequest (options: { | |||
119 | 126 | ||
120 | export { | 127 | export { |
121 | makeGetRequest, | 128 | makeGetRequest, |
122 | makePostUploadRequest, | 129 | makeUploadRequest, |
123 | makePostBodyRequest, | 130 | makePostBodyRequest, |
124 | makePutBodyRequest, | 131 | makePutBodyRequest, |
125 | makeDeleteRequest | 132 | makeDeleteRequest |