1
0
Fork 0
peertube/shared/extra-utils/feeds/feeds.ts
Chocobozzz 94565d52bb
Shared utils -> extra-utils
Because they need dev dependencies
2019-04-24 16:25:52 +02:00

32 lines
813 B
TypeScript

import * as request from 'supertest'
type FeedType = 'videos' | 'video-comments'
function getXMLfeed (url: string, feed: FeedType, format?: string) {
const path = '/feeds/' + feed + '.xml'
return request(url)
.get(path)
.query((format) ? { format: format } : {})
.set('Accept', 'application/xml')
.expect(200)
.expect('Content-Type', /xml/)
}
function getJSONfeed (url: string, feed: FeedType, query: any = {}) {
const path = '/feeds/' + feed + '.json'
return request(url)
.get(path)
.query(query)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
}
// ---------------------------------------------------------------------------
export {
getXMLfeed,
getJSONfeed
}