import { decode } from 'querystring'
import request from 'supertest'
import { URL } from 'url'
-import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { buildAbsoluteFixturePath, pick } from '@shared/core-utils'
import { HttpStatusCode } from '@shared/models'
export type CommonRequestParams = {
expectedStatus?: HttpStatusCode
}
-function makeRawRequest (url: string, expectedStatus?: HttpStatusCode, range?: string) {
- const { host, protocol, pathname } = new URL(url)
+function makeRawRequest (options: {
+ url: string
+ token?: string
+ expectedStatus?: HttpStatusCode
+ range?: string
+ query?: { [ id: string ]: string }
+}) {
+ const { host, protocol, pathname } = new URL(options.url)
+
+ return makeGetRequest({
+ url: `${protocol}//${host}`,
+ path: pathname,
+ contentType: undefined,
- return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, expectedStatus, range })
+ ...pick(options, [ 'expectedStatus', 'range', 'token', 'query' ])
+ })
}
function makeGetRequest (options: CommonRequestParams & {