Promise.prototype.finally: add more tests

- per https://github.com/tc39/ecma262/pull/1083#issuecomment-361775023
This commit is contained in:
Jordan Harband 2018-01-30 15:59:42 -08:00 committed by Rick Waldron
parent 1989f0fe6d
commit 03da22868a

View File

@ -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);
@ -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`');