Skip to content

Commit

Permalink
test: add test for promisify customPromisifyArgs
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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]>
  • Loading branch information
giltayar authored and Olivier Martin committed May 19, 2017
1 parent 0170dc6 commit 5c74efe
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-util-promisify.js
Original file line number Diff line number Diff line change
@@ -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();

Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit 5c74efe

Please sign in to comment.