]>
Commit | Line | Data |
---|---|---|
d525fc39 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import * as request from 'supertest' | |
d4681c00 | 4 | import { VideosSearchQuery } from '../../models/search' |
d175a6f7 | 5 | import { immutableAssign } from '../miscs/miscs' |
d525fc39 C |
6 | |
7 | function searchVideo (url: string, search: string) { | |
8 | const path = '/api/v1/search/videos' | |
60919831 C |
9 | |
10 | const query = { sort: '-publishedAt', search: search } | |
d525fc39 C |
11 | const req = request(url) |
12 | .get(path) | |
60919831 | 13 | .query(query) |
d525fc39 C |
14 | .set('Accept', 'application/json') |
15 | ||
16 | return req.expect(200) | |
17 | .expect('Content-Type', /json/) | |
18 | } | |
19 | ||
20 | function searchVideoWithToken (url: string, search: string, token: string, query: { nsfw?: boolean } = {}) { | |
21 | const path = '/api/v1/search/videos' | |
22 | const req = request(url) | |
23 | .get(path) | |
24 | .set('Authorization', 'Bearer ' + token) | |
25 | .query(immutableAssign(query, { sort: '-publishedAt', search })) | |
26 | .set('Accept', 'application/json') | |
27 | ||
28 | return req.expect(200) | |
29 | .expect('Content-Type', /json/) | |
30 | } | |
31 | ||
d525fc39 C |
32 | function searchVideoWithSort (url: string, search: string, sort: string) { |
33 | const path = '/api/v1/search/videos' | |
34 | ||
60919831 C |
35 | const query = { search, sort } |
36 | ||
d525fc39 C |
37 | return request(url) |
38 | .get(path) | |
60919831 | 39 | .query(query) |
d525fc39 C |
40 | .set('Accept', 'application/json') |
41 | .expect(200) | |
42 | .expect('Content-Type', /json/) | |
43 | } | |
44 | ||
45 | function advancedVideosSearch (url: string, options: VideosSearchQuery) { | |
46 | const path = '/api/v1/search/videos' | |
47 | ||
48 | return request(url) | |
49 | .get(path) | |
50 | .query(options) | |
51 | .set('Accept', 'application/json') | |
52 | .expect(200) | |
53 | .expect('Content-Type', /json/) | |
54 | } | |
55 | ||
56 | // --------------------------------------------------------------------------- | |
57 | ||
58 | export { | |
59 | searchVideo, | |
60 | advancedVideosSearch, | |
61 | searchVideoWithToken, | |
d525fc39 C |
62 | searchVideoWithSort |
63 | } |