adding tests and fixing a bug where an error would be thrown when comparing an object and null
This commit is contained in:
parent
effa9de53f
commit
5ae260820e
|
|
@ -11,9 +11,21 @@ describe('Utils', function() {
|
|||
var objD = [{
|
||||
foo: ['bar']
|
||||
}];
|
||||
var objE, objF;
|
||||
var objG = null;
|
||||
var objH = null;
|
||||
|
||||
expect(utils.isSame(objA, objB)).toBe(true);
|
||||
expect(utils.isSame(objC, objD)).toBe(true);
|
||||
expect(utils.isSame(objA, objD)).toBe(false);
|
||||
|
||||
expect(utils.isSame(objE, objF)).toBe(true);
|
||||
expect(utils.isSame(objA, objF)).toBe(false);
|
||||
expect(utils.isSame(objE, objA)).toBe(false);
|
||||
|
||||
expect(utils.isSame(objG, objH)).toBe(true);
|
||||
expect(utils.isSame(objA, objH)).toBe(false);
|
||||
expect(utils.isSame(objG, objA)).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ module.exports = {
|
|||
return false;
|
||||
} else if (Array.isArray(a)) {
|
||||
return !this.arraysDiffer(a, b);
|
||||
} else if (typeof a === 'object' && a !== null) {
|
||||
} else if (typeof a === 'object' && a !== null && b !== null) {
|
||||
return !this.objectsDiffer(a, b);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue