Add Promise checking to eq

Fixes #1314
This commit is contained in:
Scott Erickson
2017-06-26 19:10:19 -07:00
parent 6aa069d586
commit 6ddf64568e
3 changed files with 20 additions and 0 deletions

View File

@@ -75,6 +75,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return obj.nodeType > 0;
};
j$.isPromise = function(obj) {
return (typeof Promise !== 'undefined') && obj.constructor === Promise;
};
j$.fnNameFor = function(func) {
if (func.name) {
return func.name;

View File

@@ -209,6 +209,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
diffBuilder.record(a, b);
return false;
}
var aIsPromise = j$.isPromise(a);
var bIsPromise = j$.isPromise(b);
if (aIsPromise && bIsPromise) {
return a === b;
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.