Skip to content

Commit

Permalink
Promise.prototype.finally: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb authored and rwaldron committed Jan 31, 2018
1 parent 1989f0f commit 03da228
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ target.then = function(a, b) {
};

var originalFinallyHandler = function () {};
var anonName = Object(function () {}).name;

var result = Promise.prototype.finally.call(target, originalFinallyHandler, 2, 3);

Expand All @@ -43,11 +44,16 @@ assert.sameValue(
'Invokes `then` method with a function as the first argument'
);
assert.notSameValue(firstArg, originalFinallyHandler, 'Invokes `then` method with a different fulfillment handler');
assert.sameValue(firstArg.length, 1, 'fulfillment handler has a length of 1');
assert.sameValue(firstArg.name, anonName, 'fulfillment handler is anonymous');

assert.sameValue(
typeof secondArg,
'function',
'Invokes `then` method with a function as the second argument'
);
assert.notSameValue(secondArg, originalFinallyHandler, 'Invokes `then` method with a different fulfillment handler');
assert.notSameValue(secondArg, originalFinallyHandler, 'Invokes `then` method with a different rejection handler');
assert.sameValue(secondArg.length, 1, 'rejection handler has a length of 1');
assert.sameValue(secondArg.name, anonName, 'rejection handler is anonymous');

assert.sameValue(result, returnValue, 'Returns the result of the invocation of `then`');

0 comments on commit 03da228

Please sign in to comment.