Skip to content

Commit b15cfd4

Browse files
test: more
1 parent d642eba commit b15cfd4

File tree

3 files changed

+244
-0
lines changed

3 files changed

+244
-0
lines changed

lib/__tests__/HookTester.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,50 @@ class HookTester {
665665
);
666666
}
667667

668+
{
669+
const hook = this.createHook(["x"], `${type}SinglePromiseWithUndefinedArg`);
670+
hook.tapPromise("promise", (arg) => {
671+
result[`${type}SinglePromiseWithUndefinedCalled1`] = arg;
672+
return Promise.resolve(undefined);
673+
});
674+
result[`${type}SinglePromiseWithUndefined`] = await this.gainResult((cb) =>
675+
hook[type](42, cb)
676+
);
677+
}
678+
679+
{
680+
const hook = this.createHook(["x"], `${type}SinglePromiseWithNullArg`);
681+
hook.tapPromise("promise", (arg) => {
682+
result[`${type}SinglePromiseWithNullArgCalled1`] = arg;
683+
return Promise.resolve(null);
684+
});
685+
result[`${type}SinglePromiseWithNullArg`] = await this.gainResult((cb) =>
686+
hook[type](42, cb)
687+
);
688+
}
689+
690+
{
691+
const hook = this.createHook(["x"], `${type}SinglePromiseWithZeroArg`);
692+
hook.tapPromise("promise", (arg) => {
693+
result[`${type}SinglePromiseWithZeroArgCalled1`] = arg;
694+
return Promise.resolve(0);
695+
});
696+
result[`${type}SinglePromiseWithZeroArg`] = await this.gainResult((cb) =>
697+
hook[type](42, cb)
698+
);
699+
}
700+
701+
{
702+
const hook = this.createHook(["x"], `${type}SinglePromiseWithEmptyStringArg`);
703+
hook.tapPromise("promise", (arg) => {
704+
result[`${type}SinglePromiseWithEmptyStringArgCalled1`] = arg;
705+
return Promise.resolve('');
706+
});
707+
result[`${type}SinglePromiseWithEmptyStringArg`] = await this.gainResult((cb) =>
708+
hook[type](42, cb)
709+
);
710+
}
711+
668712
{
669713
const hook = this.createHook(["x"], `${type}SinglePromiseWithNullReject`);
670714
// eslint-disable-next-line prefer-promise-reject-errors

lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,38 @@ Object {
199199
"error": "Tap function (tapPromise) rejects \\"\\" value",
200200
"type": "async",
201201
},
202+
"callAsyncSinglePromiseWithEmptyStringArg": Object {
203+
"type": "async",
204+
"value": "",
205+
},
206+
"callAsyncSinglePromiseWithEmptyStringArgCalled1": 42,
202207
"callAsyncSinglePromiseWithFalseReject": Object {
203208
"error": "Tap function (tapPromise) rejects \\"false\\" value",
204209
"type": "async",
205210
},
211+
"callAsyncSinglePromiseWithNullArg": Object {
212+
"type": "async",
213+
"value": null,
214+
},
215+
"callAsyncSinglePromiseWithNullArgCalled1": 42,
206216
"callAsyncSinglePromiseWithNullReject": Object {
207217
"error": "Tap function (tapPromise) rejects \\"null\\" value",
208218
"type": "async",
209219
},
220+
"callAsyncSinglePromiseWithUndefined": Object {
221+
"type": "async",
222+
"value": undefined,
223+
},
224+
"callAsyncSinglePromiseWithUndefinedCalled1": 42,
210225
"callAsyncSinglePromiseWithUndefinedReject": Object {
211226
"error": "Tap function (tapPromise) rejects \\"undefined\\" value",
212227
"type": "async",
213228
},
229+
"callAsyncSinglePromiseWithZeroArg": Object {
230+
"type": "async",
231+
"value": 0,
232+
},
233+
"callAsyncSinglePromiseWithZeroArgCalled1": 42,
214234
"callAsyncSinglePromiseWithZeroReject": Object {
215235
"error": "Tap function (tapPromise) rejects \\"0\\" value",
216236
"type": "async",
@@ -426,18 +446,38 @@ Object {
426446
"error": "Tap function (tapPromise) rejects \\"\\" value",
427447
"type": "promise",
428448
},
449+
"promiseSinglePromiseWithEmptyStringArg": Object {
450+
"type": "promise",
451+
"value": "",
452+
},
453+
"promiseSinglePromiseWithEmptyStringArgCalled1": 42,
429454
"promiseSinglePromiseWithFalseReject": Object {
430455
"error": "Tap function (tapPromise) rejects \\"false\\" value",
431456
"type": "promise",
432457
},
458+
"promiseSinglePromiseWithNullArg": Object {
459+
"type": "promise",
460+
"value": null,
461+
},
462+
"promiseSinglePromiseWithNullArgCalled1": 42,
433463
"promiseSinglePromiseWithNullReject": Object {
434464
"error": "Tap function (tapPromise) rejects \\"null\\" value",
435465
"type": "promise",
436466
},
467+
"promiseSinglePromiseWithUndefined": Object {
468+
"type": "promise",
469+
"value": undefined,
470+
},
471+
"promiseSinglePromiseWithUndefinedCalled1": 42,
437472
"promiseSinglePromiseWithUndefinedReject": Object {
438473
"error": "Tap function (tapPromise) rejects \\"undefined\\" value",
439474
"type": "promise",
440475
},
476+
"promiseSinglePromiseWithZeroArg": Object {
477+
"type": "promise",
478+
"value": 0,
479+
},
480+
"promiseSinglePromiseWithZeroArgCalled1": 42,
441481
"promiseSinglePromiseWithZeroReject": Object {
442482
"error": "Tap function (tapPromise) rejects \\"0\\" value",
443483
"type": "promise",
@@ -969,18 +1009,38 @@ Object {
9691009
"error": "Tap function (tapPromise) rejects \\"\\" value",
9701010
"type": "async",
9711011
},
1012+
"callAsyncSinglePromiseWithEmptyStringArg": Object {
1013+
"type": "async",
1014+
"value": undefined,
1015+
},
1016+
"callAsyncSinglePromiseWithEmptyStringArgCalled1": 42,
9721017
"callAsyncSinglePromiseWithFalseReject": Object {
9731018
"error": "Tap function (tapPromise) rejects \\"false\\" value",
9741019
"type": "async",
9751020
},
1021+
"callAsyncSinglePromiseWithNullArg": Object {
1022+
"type": "async",
1023+
"value": undefined,
1024+
},
1025+
"callAsyncSinglePromiseWithNullArgCalled1": 42,
9761026
"callAsyncSinglePromiseWithNullReject": Object {
9771027
"error": "Tap function (tapPromise) rejects \\"null\\" value",
9781028
"type": "async",
9791029
},
1030+
"callAsyncSinglePromiseWithUndefined": Object {
1031+
"type": "async",
1032+
"value": undefined,
1033+
},
1034+
"callAsyncSinglePromiseWithUndefinedCalled1": 42,
9801035
"callAsyncSinglePromiseWithUndefinedReject": Object {
9811036
"error": "Tap function (tapPromise) rejects \\"undefined\\" value",
9821037
"type": "async",
9831038
},
1039+
"callAsyncSinglePromiseWithZeroArg": Object {
1040+
"type": "async",
1041+
"value": undefined,
1042+
},
1043+
"callAsyncSinglePromiseWithZeroArgCalled1": 42,
9841044
"callAsyncSinglePromiseWithZeroReject": Object {
9851045
"error": "Tap function (tapPromise) rejects \\"0\\" value",
9861046
"type": "async",
@@ -1209,18 +1269,38 @@ Object {
12091269
"error": "Tap function (tapPromise) rejects \\"\\" value",
12101270
"type": "promise",
12111271
},
1272+
"promiseSinglePromiseWithEmptyStringArg": Object {
1273+
"type": "promise",
1274+
"value": undefined,
1275+
},
1276+
"promiseSinglePromiseWithEmptyStringArgCalled1": 42,
12121277
"promiseSinglePromiseWithFalseReject": Object {
12131278
"error": "Tap function (tapPromise) rejects \\"false\\" value",
12141279
"type": "promise",
12151280
},
1281+
"promiseSinglePromiseWithNullArg": Object {
1282+
"type": "promise",
1283+
"value": undefined,
1284+
},
1285+
"promiseSinglePromiseWithNullArgCalled1": 42,
12161286
"promiseSinglePromiseWithNullReject": Object {
12171287
"error": "Tap function (tapPromise) rejects \\"null\\" value",
12181288
"type": "promise",
12191289
},
1290+
"promiseSinglePromiseWithUndefined": Object {
1291+
"type": "promise",
1292+
"value": undefined,
1293+
},
1294+
"promiseSinglePromiseWithUndefinedCalled1": 42,
12201295
"promiseSinglePromiseWithUndefinedReject": Object {
12211296
"error": "Tap function (tapPromise) rejects \\"undefined\\" value",
12221297
"type": "promise",
12231298
},
1299+
"promiseSinglePromiseWithZeroArg": Object {
1300+
"type": "promise",
1301+
"value": undefined,
1302+
},
1303+
"promiseSinglePromiseWithZeroArgCalled1": 42,
12241304
"promiseSinglePromiseWithZeroReject": Object {
12251305
"error": "Tap function (tapPromise) rejects \\"0\\" value",
12261306
"type": "promise",

0 commit comments

Comments
 (0)