Browse Source

test: add test for promisify customPromisifyArgs

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Gil Tayar 8 years ago
committed by Anna Henningsen
parent
commit
e965ed16c1
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 17
      test/parallel/test-util-promisify.js

17
test/parallel/test-util-promisify.js

@ -1,9 +1,11 @@
'use strict';
// Flags: --expose-internals
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const vm = require('vm');
const { promisify } = require('util');
const { customPromisifyArgs } = require('internal/util');
common.crashOnUnhandledRejection();
@ -42,6 +44,21 @@ const stat = promisify(fs.stat);
'be a function');
}
{
const firstValue = 5;
const secondValue = 17;
function fn(callback) {
callback(null, firstValue, secondValue);
}
fn[customPromisifyArgs] = ['first', 'second'];
promisify(fn)().then(common.mustCall((obj) => {
assert.deepStrictEqual(obj, {first: firstValue, second: secondValue});
}));
}
{
const fn = vm.runInNewContext('(function() {})');
assert.notStrictEqual(Object.getPrototypeOf(promisify(fn)),

Loading…
Cancel
Save