-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Test shallowEquality #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
if (valA !== valB) { | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dead code. This is already present in the if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
The file should be named |
@emmenko Okay.Sorry I didn't notice it. |
Np :) |
describe('shallowEqualScalar', () => { | ||
it('should compare the given arguments shallowly', () => { | ||
|
||
expect(shallowEqualScalar(null, undefined)).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only test things whose typeof
is object
. This includes null
, but not undefined
.
describe('Utils', () => { | ||
// More info: https://github.com/gaearon/redux/pull/75#issuecomment-111635748 | ||
describe('shallowEqualScalar', () => { | ||
it('should compare the given objects shallowly', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon I don't know how to concisely describe shallowEqualScalar. Help please? or just leave it be since I have left the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“should compare shallowly but bail out on object fields”
// More info: https://github.com/gaearon/redux/pull/75#issuecomment-111635748 | ||
describe('shallowEqualScalar', () => { | ||
it('returns true if both arguments are the same object referentially', () => { | ||
const o = {a: 1, b: 2}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tweak the style to use spaces inside object definitions. ({a : 1}
=> { a: 1 }
). This doesn't concern arrays, just objects.
@gaearon Can you take a look now ? |
Currently the following test fails: expect(shallowEqual({a: NaN}, {a: NaN})).toBe(true) Maybe we should fix that. |
@@ -19,12 +19,6 @@ export default function shallowEqual(objA, objB) { | |||
return false; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this line?
@ooflorent Done. Anything else? |
No description provided.