1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as request from 'supertest'
4 import { VideosSearchQuery } from '../../models/search'
5 import { immutableAssign } from '../miscs/miscs'
7 function searchVideo (url: string, search: string) {
8 const path = '/api/v1/search/videos'
10 const query = { sort: '-publishedAt', search: search }
11 const req = request(url)
14 .set('Accept', 'application/json')
16 return req.expect(200)
17 .expect('Content-Type', /json/)
20 function searchVideoWithToken (url: string, search: string, token: string, query: { nsfw?: boolean } = {}) {
21 const path = '/api/v1/search/videos'
22 const req = request(url)
24 .set('Authorization', 'Bearer ' + token)
25 .query(immutableAssign(query, { sort: '-publishedAt', search }))
26 .set('Accept', 'application/json')
28 return req.expect(200)
29 .expect('Content-Type', /json/)
32 function searchVideoWithSort (url: string, search: string, sort: string) {
33 const path = '/api/v1/search/videos'
35 const query = { search, sort }
40 .set('Accept', 'application/json')
42 .expect('Content-Type', /json/)
45 function advancedVideosSearch (url: string, options: VideosSearchQuery) {
46 const path = '/api/v1/search/videos'
51 .set('Accept', 'application/json')
53 .expect('Content-Type', /json/)
56 // ---------------------------------------------------------------------------