Permalink
Browse files

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>
  • Loading branch information...
giltayar authored and addaleax committed Apr 18, 2017
1 parent 3ea2301 commit e965ed16c111f219116a5e8ea6847f5b98b5d0be
Showing with 17 additions and 0 deletions.
  1. +17 −0 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)),

0 comments on commit e965ed1

Please sign in to comment.