2017-09-22 02:13:43 -05:00
|
|
|
import * as request from 'supertest'
|
|
|
|
|
2018-08-13 09:57:13 -05:00
|
|
|
function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) {
|
2017-09-22 02:13:43 -05:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.post(path)
|
2018-08-13 09:57:13 -05:00
|
|
|
.send({ reason })
|
2017-09-22 02:13:43 -05:00
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
2018-08-13 09:57:13 -05:00
|
|
|
function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) {
|
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.put(path)
|
|
|
|
.send({ reason })
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
2018-08-14 02:08:47 -05:00
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
2018-08-13 09:57:13 -05:00
|
|
|
|
2017-12-28 09:26:28 -06:00
|
|
|
function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
|
2017-10-10 03:02:18 -05:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
2017-09-22 02:13:43 -05:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.delete(path)
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
|
2017-10-10 03:02:18 -05:00
|
|
|
const path = '/api/v1/videos/blacklist/'
|
2017-09-22 02:13:43 -05:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.get(path)
|
|
|
|
.query({ sort: 'createdAt' })
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
|
2017-10-10 03:02:18 -05:00
|
|
|
const path = '/api/v1/videos/blacklist/'
|
2017-09-22 02:13:43 -05:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.get(path)
|
|
|
|
.query({ sort: sort })
|
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
addVideoToBlacklist,
|
|
|
|
removeVideoFromBlacklist,
|
|
|
|
getBlacklistedVideosList,
|
2018-08-13 09:57:13 -05:00
|
|
|
getSortedBlacklistedVideosList,
|
|
|
|
updateVideoBlacklist
|
2017-09-22 02:13:43 -05:00
|
|
|
}
|