aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/feeds/feeds.ts
blob: fb480b7043e00847bfc5fb45e47143a825ecc2ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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) {
  const path = '/feeds/' + feed + '.json'

  return request(url)
          .get(path)
          .set('Accept', 'application/json')
          .expect(200)
          .expect('Content-Type', /json/)
}

// ---------------------------------------------------------------------------

export {
  getXMLfeed,
  getJSONfeed
}