@tramvai/test-helpers 1.84.2 → 1.85.0
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 +10 -5
- package/lib/index.js +10 -5
- package/lib/parseHtml.d.ts +1 -1
- package/lib/render.d.ts +1 -1
- package/lib/request.d.ts +2 -1
- package/package.json +4 -3
package/lib/index.es.js
CHANGED
|
@@ -4,16 +4,16 @@ import { walkOfModules, getModuleParameters } from '@tramvai/core';
|
|
|
4
4
|
import { createMockDi } from '@tramvai/test-mocks';
|
|
5
5
|
|
|
6
6
|
const parseHtml = (html, parserOptions = { blockTextElements: { script: false, style: false } }) => {
|
|
7
|
-
var _a;
|
|
7
|
+
var _a, _b, _c;
|
|
8
8
|
if (!html) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
const parsed = parse(html, parserOptions);
|
|
12
12
|
return {
|
|
13
13
|
parsed,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
application: (
|
|
14
|
+
body: (_a = parsed.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML,
|
|
15
|
+
head: (_b = parsed.querySelector('head')) === null || _b === void 0 ? void 0 : _b.innerHTML,
|
|
16
|
+
application: (_c = parsed.querySelector('.application')) === null || _c === void 0 ? void 0 : _c.innerHTML,
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -50,7 +50,12 @@ const renderFactory = (request) => async (path, { method = 'get', parserOptions,
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const requestFactory = (appOrUrl) => {
|
|
53
|
-
|
|
53
|
+
let server = appOrUrl;
|
|
54
|
+
if (typeof appOrUrl === 'object' && 'ready' in appOrUrl) {
|
|
55
|
+
appOrUrl.ready();
|
|
56
|
+
server = appOrUrl.server;
|
|
57
|
+
}
|
|
58
|
+
const request = supertest(server);
|
|
54
59
|
return (path, { method = 'get' } = {}) => {
|
|
55
60
|
return request[method](path);
|
|
56
61
|
};
|
package/lib/index.js
CHANGED
|
@@ -12,16 +12,16 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
var supertest__default = /*#__PURE__*/_interopDefaultLegacy(supertest);
|
|
13
13
|
|
|
14
14
|
const parseHtml = (html, parserOptions = { blockTextElements: { script: false, style: false } }) => {
|
|
15
|
-
var _a;
|
|
15
|
+
var _a, _b, _c;
|
|
16
16
|
if (!html) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
const parsed = nodeHtmlParser.parse(html, parserOptions);
|
|
20
20
|
return {
|
|
21
21
|
parsed,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
application: (
|
|
22
|
+
body: (_a = parsed.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML,
|
|
23
|
+
head: (_b = parsed.querySelector('head')) === null || _b === void 0 ? void 0 : _b.innerHTML,
|
|
24
|
+
application: (_c = parsed.querySelector('.application')) === null || _c === void 0 ? void 0 : _c.innerHTML,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -58,7 +58,12 @@ const renderFactory = (request) => async (path, { method = 'get', parserOptions,
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
const requestFactory = (appOrUrl) => {
|
|
61
|
-
|
|
61
|
+
let server = appOrUrl;
|
|
62
|
+
if (typeof appOrUrl === 'object' && 'ready' in appOrUrl) {
|
|
63
|
+
appOrUrl.ready();
|
|
64
|
+
server = appOrUrl.server;
|
|
65
|
+
}
|
|
66
|
+
const request = supertest__default["default"](server);
|
|
62
67
|
return (path, { method = 'get' } = {}) => {
|
|
63
68
|
return request[method](path);
|
|
64
69
|
};
|
package/lib/parseHtml.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Options as ParserOptions } from 'node-html-parser';
|
|
|
2
2
|
export declare type ParseOptions = Partial<ParserOptions>;
|
|
3
3
|
export declare const parseHtml: (html: string, parserOptions?: ParseOptions) => {
|
|
4
4
|
parsed: import("node-html-parser").HTMLElement;
|
|
5
|
-
head: string;
|
|
6
5
|
body: string;
|
|
6
|
+
head: string;
|
|
7
7
|
application: string;
|
|
8
8
|
} | null;
|
package/lib/render.d.ts
CHANGED
package/lib/request.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import supertest from 'supertest';
|
|
2
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
3
|
import type { Application } from 'express';
|
|
3
|
-
export declare const requestFactory: (appOrUrl: Application | string) => (path: string, { method }?: {
|
|
4
|
+
export declare const requestFactory: (appOrUrl: Application | FastifyInstance | string) => (path: string, { method }?: {
|
|
4
5
|
method?: "get" | "post" | "put" | undefined;
|
|
5
6
|
}) => supertest.Test;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/test-helpers",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.85.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"build-for-publish": "true"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tramvai/core": "1.
|
|
22
|
-
"@tramvai/test-mocks": "1.
|
|
21
|
+
"@tramvai/core": "1.85.0",
|
|
22
|
+
"@tramvai/test-mocks": "1.85.0",
|
|
23
23
|
"@types/express": "^4.17.1",
|
|
24
24
|
"@types/supertest": "^2.0.11",
|
|
25
25
|
"express": "^4.17.1",
|
|
26
|
+
"fastify": "^3.27.4",
|
|
26
27
|
"node-html-parser": "^3.0.4",
|
|
27
28
|
"supertest": "^6.1.3"
|
|
28
29
|
},
|