1 /* tslint:disable:no-unused-expression */
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'
9 const req = request(url)
11 .query({ sort: '-publishedAt', search })
12 .set('Accept', 'application/json')
14 return req.expect(200)
15 .expect('Content-Type', /json/)
18 function searchVideoWithToken (url: string, search: string, token: string, query: { nsfw?: boolean } = {}) {
19 const path = '/api/v1/search/videos'
20 const req = request(url)
22 .set('Authorization', 'Bearer ' + token)
23 .query(immutableAssign(query, { sort: '-publishedAt', search }))
24 .set('Accept', 'application/json')
26 return req.expect(200)
27 .expect('Content-Type', /json/)
30 function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
31 const path = '/api/v1/search/videos'
33 const req = request(url)
39 if (sort) req.query({ sort })
41 return req.set('Accept', 'application/json')
43 .expect('Content-Type', /json/)
46 function searchVideoWithSort (url: string, search: string, sort: string) {
47 const path = '/api/v1/search/videos'
53 .set('Accept', 'application/json')
55 .expect('Content-Type', /json/)
58 function advancedVideosSearch (url: string, options: VideosSearchQuery) {
59 const path = '/api/v1/search/videos'
64 .set('Accept', 'application/json')
66 .expect('Content-Type', /json/)
69 // ---------------------------------------------------------------------------
75 searchVideoWithPagination,