Skip to content

Commit e965ed1

Browse files
giltayaraddaleax
authored andcommitted
test: add test for promisify customPromisifyArgs
PR-URL: #12442 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: William Kapke <william.kapke@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
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

Lines changed: 17 additions & 0 deletions
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)