PeerTube/server/tests/utils/feeds/feeds.ts

33 lines
840 B
TypeScript

import * as request from 'supertest'
import { readFileBufferPromise } from '../../../helpers/core-utils'
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) {
const path = '/feeds/' + feed + '.json'
return request(url)
.get(path)
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
}
// ---------------------------------------------------------------------------
export {
getXMLfeed,
getJSONfeed
}