]>
Commit | Line | Data |
---|---|---|
966eb053 | 1 | import * as request from 'supertest' |
2d53be02 | 2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
966eb053 | 3 | |
5beb89f2 | 4 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' |
fe3a55b0 C |
5 | |
6 | function getXMLfeed (url: string, feed: FeedType, format?: string) { | |
7 | const path = '/feeds/' + feed + '.xml' | |
966eb053 RK |
8 | |
9 | return request(url) | |
10 | .get(path) | |
11 | .query((format) ? { format: format } : {}) | |
12 | .set('Accept', 'application/xml') | |
2d53be02 | 13 | .expect(HttpStatusCode.OK_200) |
966eb053 RK |
14 | .expect('Content-Type', /xml/) |
15 | } | |
16 | ||
2d53be02 | 17 | function getJSONfeed (url: string, feed: FeedType, query: any = {}, statusCodeExpected = HttpStatusCode.OK_200) { |
fe3a55b0 | 18 | const path = '/feeds/' + feed + '.json' |
966eb053 RK |
19 | |
20 | return request(url) | |
21 | .get(path) | |
662fb3ab | 22 | .query(query) |
966eb053 | 23 | .set('Accept', 'application/json') |
18490b07 | 24 | .expect(statusCodeExpected) |
966eb053 RK |
25 | .expect('Content-Type', /json/) |
26 | } | |
27 | ||
28 | // --------------------------------------------------------------------------- | |
29 | ||
30 | export { | |
31 | getXMLfeed, | |
32 | getJSONfeed | |
33 | } |