1
0
Fork 0
peertube/shared/utils/feeds/feeds.ts

33 lines
813 B
TypeScript
Raw Normal View History

import * as request from 'supertest'
2018-06-08 14:34:37 -04:00
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/)
}
2018-09-13 03:48:34 -04:00
function getJSONfeed (url: string, feed: FeedType, query: any = {}) {
2018-06-08 14:34:37 -04:00
const path = '/feeds/' + feed + '.json'
return request(url)
.get(path)
2018-09-13 03:48:34 -04:00
.query(query)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
}
// ---------------------------------------------------------------------------
export {
getXMLfeed,
getJSONfeed
}