Skip to content

Commit e965ed1

Browse files
giltayaraddaleax
authored andcommitted
test: add test for promisify customPromisifyArgs
PR-URL: #12442 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: William Kapke <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Teddy Katz <[email protected]>
1 parent 3ea2301 commit e965ed1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/parallel/test-util-promisify.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use strict';
2+
// Flags: --expose-internals
23
const common = require('../common');
34
const assert = require('assert');
45
const fs = require('fs');
56
const vm = require('vm');
67
const { promisify } = require('util');
8+
const { customPromisifyArgs } = require('internal/util');
79

810
common.crashOnUnhandledRejection();
911

@@ -42,6 +44,21 @@ const stat = promisify(fs.stat);
4244
'be a function');
4345
}
4446

47+
{
48+
const firstValue = 5;
49+
const secondValue = 17;
50+
51+
function fn(callback) {
52+
callback(null, firstValue, secondValue);
53+
}
54+
55+
fn[customPromisifyArgs] = ['first', 'second'];
56+
57+
promisify(fn)().then(common.mustCall((obj) => {
58+
assert.deepStrictEqual(obj, {first: firstValue, second: secondValue});
59+
}));
60+
}
61+
4562
{
4663
const fn = vm.runInNewContext('(function() {})');
4764
assert.notStrictEqual(Object.getPrototypeOf(promisify(fn)),

0 commit comments

Comments
 (0)