@tramvai/test-helpers 2.22.0 → 2.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.es.js CHANGED
@@ -56,11 +56,14 @@ const requestFactory = (appOrUrl) => {
56
56
  server = appOrUrl.server;
57
57
  }
58
58
  const request = supertest(server);
59
- return (path, { method = 'get', body, contentType, } = {}) => {
59
+ return (path, { method = 'get', body, contentType, headers = {}, } = {}) => {
60
60
  const instance = request[method](path);
61
61
  if (contentType) {
62
62
  instance.type(contentType);
63
63
  }
64
+ for (const header in headers) {
65
+ instance.set(header, headers[header]);
66
+ }
64
67
  if (body) {
65
68
  return instance.send(body);
66
69
  }
package/lib/index.js CHANGED
@@ -64,11 +64,14 @@ const requestFactory = (appOrUrl) => {
64
64
  server = appOrUrl.server;
65
65
  }
66
66
  const request = supertest__default["default"](server);
67
- return (path, { method = 'get', body, contentType, } = {}) => {
67
+ return (path, { method = 'get', body, contentType, headers = {}, } = {}) => {
68
68
  const instance = request[method](path);
69
69
  if (contentType) {
70
70
  instance.type(contentType);
71
71
  }
72
+ for (const header in headers) {
73
+ instance.set(header, headers[header]);
74
+ }
72
75
  if (body) {
73
76
  return instance.send(body);
74
77
  }
package/lib/request.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import supertest from 'supertest';
2
2
  import type { FastifyInstance } from 'fastify';
3
3
  import type { Application } from 'express';
4
- export declare const requestFactory: (appOrUrl: Application | FastifyInstance | string) => (path: string, { method, body, contentType, }?: {
5
- method?: "get" | "post" | "put" | undefined;
4
+ export declare const requestFactory: (appOrUrl: Application | FastifyInstance | string) => (path: string, { method, body, contentType, headers, }?: {
5
+ method?: "get" | "post" | "put" | "delete" | undefined;
6
6
  body?: Record<string, any> | undefined;
7
7
  contentType?: "json" | "form" | undefined;
8
+ headers?: Record<string, string> | undefined;
8
9
  }) => supertest.Test;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/test-helpers",
3
- "version": "2.22.0",
3
+ "version": "2.24.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "build-for-publish": "true"
19
19
  },
20
20
  "dependencies": {
21
- "@tramvai/core": "2.22.0",
22
- "@tramvai/test-mocks": "2.22.0",
21
+ "@tramvai/core": "2.24.3",
22
+ "@tramvai/test-mocks": "2.24.3",
23
23
  "@types/express": "^4.17.1",
24
24
  "@types/supertest": "^2.0.11",
25
25
  "fastify": "^3.29.0",
@@ -27,7 +27,7 @@
27
27
  "supertest": "^6.1.3"
28
28
  },
29
29
  "peerDependencies": {
30
- "@tinkoff/dippy": "0.8.2",
30
+ "@tinkoff/dippy": "0.8.3",
31
31
  "tslib": "^2.0.3"
32
32
  },
33
33
  "devDependencies": {},