From 94565d52bb2883e09f16d1363170ac9c0dccb7a1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Apr 2019 15:26:15 +0200 Subject: Shared utils -> extra-utils Because they need dev dependencies --- shared/extra-utils/feeds/feeds.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 shared/extra-utils/feeds/feeds.ts (limited to 'shared/extra-utils/feeds/feeds.ts') diff --git a/shared/extra-utils/feeds/feeds.ts b/shared/extra-utils/feeds/feeds.ts new file mode 100644 index 000000000..af6df2b20 --- /dev/null +++ b/shared/extra-utils/feeds/feeds.ts @@ -0,0 +1,32 @@ +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 +} -- cgit v1.2.3