node-tdd 6.1.0 → 6.2.1
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.
|
@@ -13,6 +13,14 @@ export const tryParseJson = (value) => {
|
|
|
13
13
|
|
|
14
14
|
export const nullAsString = (value) => (value === null ? 'null' : value);
|
|
15
15
|
|
|
16
|
+
export const convertHeaders = (array) => {
|
|
17
|
+
const obj = {};
|
|
18
|
+
for (let idx = 0; idx < array.length; idx += 2) {
|
|
19
|
+
obj[array[idx].toLowerCase()] = array[idx + 1];
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
};
|
|
23
|
+
|
|
16
24
|
export const rewriteHeaders = (headers, fn = (k, v) => v) => {
|
|
17
25
|
if (headers === undefined) {
|
|
18
26
|
return {};
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
buildKey,
|
|
21
21
|
tryParseJson,
|
|
22
22
|
nullAsString,
|
|
23
|
-
rewriteHeaders
|
|
23
|
+
rewriteHeaders,
|
|
24
|
+
convertHeaders
|
|
24
25
|
} from './request-recorder/util.js';
|
|
25
26
|
|
|
26
27
|
const nockBack = nock.back;
|
|
@@ -176,10 +177,14 @@ export default (opts) => {
|
|
|
176
177
|
);
|
|
177
178
|
// eslint-disable-next-line no-param-reassign
|
|
178
179
|
scope.filteringRequestBody = (body) => {
|
|
180
|
+
const idx = pendingMocks.findIndex((m) => m.idx === scopeIdx);
|
|
181
|
+
const record = pendingMocks[idx].record;
|
|
182
|
+
if (record?.body === null) {
|
|
183
|
+
return scope.body;
|
|
184
|
+
}
|
|
179
185
|
if (anyFlagPresent(['magic', 'body'])) {
|
|
180
|
-
const idx = pendingMocks.findIndex((m) => m.idx === scopeIdx);
|
|
181
186
|
const requestBody = nullAsString(tryParseJson(body));
|
|
182
|
-
updateAndRestoreModifiers(
|
|
187
|
+
updateAndRestoreModifiers(record, 'body', scope.body, requestBody);
|
|
183
188
|
return scope.body;
|
|
184
189
|
}
|
|
185
190
|
return body;
|
|
@@ -267,7 +272,7 @@ export default (opts) => {
|
|
|
267
272
|
afterRecord: (recordings) => JSON.stringify(recordings.map((r) => ({
|
|
268
273
|
...r,
|
|
269
274
|
body: tryParseJson(r.body),
|
|
270
|
-
rawHeaders: opts.stripHeaders === true ? undefined : r.rawHeaders,
|
|
275
|
+
rawHeaders: opts.stripHeaders === true ? undefined : convertHeaders(r.rawHeaders),
|
|
271
276
|
reqheaders: rewriteHeaders(r.reqheaders, overwriteHeaders)
|
|
272
277
|
})), null, 2)
|
|
273
278
|
}, resolve);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-tdd",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.1
|
|
4
|
+
"version": "6.2.1",
|
|
5
5
|
"description": "Drop in extension for mocha to abstract commonly used test setups",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/blackflux/node-tdd#readme",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@aws-sdk/client-sqs": "3.
|
|
45
|
-
"@babel/core": "7.
|
|
46
|
-
"@babel/eslint-parser": "7.
|
|
47
|
-
"@babel/register": "7.
|
|
44
|
+
"@aws-sdk/client-sqs": "3.821.0",
|
|
45
|
+
"@babel/core": "7.27.4",
|
|
46
|
+
"@babel/eslint-parser": "7.27.1",
|
|
47
|
+
"@babel/register": "7.27.1",
|
|
48
48
|
"@blackflux/axios": "3.0.2",
|
|
49
49
|
"@blackflux/eslint-plugin-rules": "4.0.1",
|
|
50
|
-
"@blackflux/robo-config-plugin": "10.0.
|
|
50
|
+
"@blackflux/robo-config-plugin": "10.0.6",
|
|
51
51
|
"aws-sdk-wrap": "14.0.1",
|
|
52
52
|
"c8": "10.1.3",
|
|
53
53
|
"chai": "5.2.0",
|
|
54
|
-
"eslint": "9.
|
|
54
|
+
"eslint": "9.28.0",
|
|
55
55
|
"eslint-config-airbnb-base": "15.0.0",
|
|
56
56
|
"eslint-plugin-import": "2.31.0",
|
|
57
57
|
"eslint-plugin-json": "4.0.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"lodash.get": "4.4.2",
|
|
81
81
|
"lru-cache-ext": "5.0.1",
|
|
82
82
|
"minimist": "1.2.8",
|
|
83
|
-
"nock": "
|
|
83
|
+
"nock": "13.5.6",
|
|
84
84
|
"normalize-url": "2.0.1",
|
|
85
85
|
"object-scan": "20.0.1",
|
|
86
86
|
"smart-fs": "5.0.2",
|