From 9639bd175726b73f8fe664b5ced12a72407b1f0b Mon Sep 17 00:00:00 2001 From: buoyantair Date: Mon, 29 Oct 2018 22:18:31 +0530 Subject: Move utils to /shared Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336 --- shared/utils/feeds/feeds.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 shared/utils/feeds/feeds.ts (limited to 'shared/utils/feeds') diff --git a/shared/utils/feeds/feeds.ts b/shared/utils/feeds/feeds.ts new file mode 100644 index 000000000..af6df2b20 --- /dev/null +++ b/shared/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