]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/feeds/feeds.ts
Fix migration and test
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / feeds / feeds.ts
CommitLineData
966eb053 1import * as request from 'supertest'
966eb053 2
5beb89f2 3type FeedType = 'videos' | 'video-comments' | 'subscriptions'
fe3a55b0
C
4
5function getXMLfeed (url: string, feed: FeedType, format?: string) {
6 const path = '/feeds/' + feed + '.xml'
966eb053
RK
7
8 return request(url)
9 .get(path)
10 .query((format) ? { format: format } : {})
11 .set('Accept', 'application/xml')
12 .expect(200)
13 .expect('Content-Type', /xml/)
14}
15
18490b07 16function getJSONfeed (url: string, feed: FeedType, query: any = {}, statusCodeExpected = 200) {
fe3a55b0 17 const path = '/feeds/' + feed + '.json'
966eb053
RK
18
19 return request(url)
20 .get(path)
662fb3ab 21 .query(query)
966eb053 22 .set('Accept', 'application/json')
18490b07 23 .expect(statusCodeExpected)
966eb053
RK
24 .expect('Content-Type', /json/)
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 getXMLfeed,
31 getJSONfeed
32}