feeds.ts 813 B

1234567891011121314151617181920212223242526272829303132
  1. import * as request from 'supertest'
  2. type FeedType = 'videos' | 'video-comments'
  3. function getXMLfeed (url: string, feed: FeedType, format?: string) {
  4. const path = '/feeds/' + feed + '.xml'
  5. return request(url)
  6. .get(path)
  7. .query((format) ? { format: format } : {})
  8. .set('Accept', 'application/xml')
  9. .expect(200)
  10. .expect('Content-Type', /xml/)
  11. }
  12. function getJSONfeed (url: string, feed: FeedType, query: any = {}) {
  13. const path = '/feeds/' + feed + '.json'
  14. return request(url)
  15. .get(path)
  16. .query(query)
  17. .set('Accept', 'application/json')
  18. .expect(200)
  19. .expect('Content-Type', /json/)
  20. }
  21. // ---------------------------------------------------------------------------
  22. export {
  23. getXMLfeed,
  24. getJSONfeed
  25. }