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'
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 searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
33 const path = '/api/v1/search/videos'
41 const req = request(url)
45 if (sort) req.query({ sort })
47 return req.set('Accept', 'application/json')
49 .expect('Content-Type', /json/)
52 function searchVideoWithSort (url: string, search: string, sort: string) {
53 const path = '/api/v1/search/videos'
55 const query = { search, sort }
60 .set('Accept', 'application/json')
62 .expect('Content-Type', /json/)
65 function advancedVideosSearch (url: string, options: VideosSearchQuery) {
66 const path = '/api/v1/search/videos'
71 .set('Accept', 'application/json')
73 .expect('Content-Type', /json/)
76 // ---------------------------------------------------------------------------
82 searchVideoWithPagination,