2017-09-22 09:13:43 +02:00
|
|
|
import * as request from 'supertest'
|
|
|
|
|
2018-08-13 16:57:13 +02:00
|
|
|
function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) {
|
2017-09-22 09:13:43 +02:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.post(path)
|
2018-08-13 16:57:13 +02:00
|
|
|
.send({ reason })
|
2017-09-22 09:13:43 +02:00
|
|
|
.set('Accept', 'application/json')
|
|
|
|
.set('Authorization', 'Bearer ' + token)
|
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
|
|
|
|
2018-08-13 16:57:13 +02: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 09:08:47 +02:00
|
|
|
.expect(specialStatus)
|
|
|
|
}
|
2018-08-13 16:57:13 +02:00
|
|
|
|
2017-12-28 16:26:28 +01:00
|
|
|
function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) {
|
2017-10-10 10:02:18 +02:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/blacklist'
|
2017-09-22 09:13:43 +02: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 10:02:18 +02:00
|
|
|
const path = '/api/v1/videos/blacklist/'
|
2017-09-22 09:13:43 +02: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 10:02:18 +02:00
|
|
|
const path = '/api/v1/videos/blacklist/'
|
2017-09-22 09:13:43 +02: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 16:57:13 +02:00
|
|
|
getSortedBlacklistedVideosList,
|
|
|
|
updateVideoBlacklist
|
2017-09-22 09:13:43 +02:00
|
|
|
}
|