From f6d0372b7a24f70d1eb790649cf08a2ffc9dea00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Tue, 11 Dec 2018 13:45:32 +0000 Subject: [PATCH] test new condition --- lib/utils.js | 6 +++++- test/unit/utils.spec.js | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index fe01e972cf..dbcbbc2b86 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -688,7 +688,11 @@ exports.stackTraceFilter = function() { * @returns {boolean} Whether or not `value` is a Promise */ exports.isPromise = function isPromise(value) { - return typeof value === 'object' && value && typeof value.then === 'function'; + return ( + typeof value === 'object' && + value !== null && + typeof value.then === 'function' + ); }; /** diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js index e5a68debd0..aaed67095d 100644 --- a/test/unit/utils.spec.js +++ b/test/unit/utils.spec.js @@ -591,6 +591,10 @@ describe('lib/utils', function() { it('should return false if the value is an object w/o a "then" function', function() { expect(utils.isPromise({}), 'to be', false); }); + + it('should return false if the object is null', function() { + expect(utils.isPromise(null), 'to be', false); + }); }); describe('escape', function() {