Merge pull request #3370 from varunrau/master

Fixed shallowEqual for arguments that are not objects
This commit is contained in:
Jim committed 2015-03-11 08:34:49 -07:00
commit 5afa657d77
2 files changed
+22

No files matched your search

+18
View File
@@ -41,6 +41,24 @@ describe('shallowEqual', function() {
).toBe(true);
});
it('returns false if arguments are not objects and not equal', function() {
expect(
shallowEqual(
1,
2
)
).toBe(false);
});
it('returns false if only one argument is not an object', function() {
expect(
shallowEqual(
1,
{}
)
).toBe(false);
})
it('returns false if first argument has too many keys', function() {
expect(
shallowEqual(
+4
View File
@@ -27,6 +27,10 @@ function shallowEqual(objA, objB) {
return false;
}
if (typeof objA !== 'object' || typeof objB !== 'object') {
return false;
}
var key;
// Test for A's keys different from B.
for (key in objA) {