2018-04-18 16:08:36 +02:00
|
|
|
import * as request from 'supertest'
|
2020-12-07 14:32:36 +01:00
|
|
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
2018-04-18 16:08:36 +02:00
|
|
|
|
2020-11-09 16:25:27 +01:00
|
|
|
type FeedType = 'videos' | 'video-comments' | 'subscriptions'
|
2018-06-08 20:34:37 +02:00
|
|
|
|
|
|
|
function getXMLfeed (url: string, feed: FeedType, format?: string) {
|
|
|
|
const path = '/feeds/' + feed + '.xml'
|
2018-04-18 16:08:36 +02:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.get(path)
|
|
|
|
.query((format) ? { format: format } : {})
|
|
|
|
.set('Accept', 'application/xml')
|
2020-12-07 14:32:36 +01:00
|
|
|
.expect(HttpStatusCode.OK_200)
|
2018-04-18 16:08:36 +02:00
|
|
|
.expect('Content-Type', /xml/)
|
|
|
|
}
|
|
|
|
|
2020-12-07 14:32:36 +01:00
|
|
|
function getJSONfeed (url: string, feed: FeedType, query: any = {}, statusCodeExpected = HttpStatusCode.OK_200) {
|
2018-06-08 20:34:37 +02:00
|
|
|
const path = '/feeds/' + feed + '.json'
|
2018-04-18 16:08:36 +02:00
|
|
|
|
|
|
|
return request(url)
|
|
|
|
.get(path)
|
2018-09-13 09:48:34 +02:00
|
|
|
.query(query)
|
2018-04-18 16:08:36 +02:00
|
|
|
.set('Accept', 'application/json')
|
2020-11-25 11:04:18 +01:00
|
|
|
.expect(statusCodeExpected)
|
2018-04-18 16:08:36 +02:00
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
getXMLfeed,
|
|
|
|
getJSONfeed
|
|
|
|
}
|