Skip to content

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

Merged
merged 1 commit into from
Jun 16, 2015
Merged

Test shallowEquality #98

merged 1 commit into from
Jun 16, 2015

Conversation

vramana
Copy link
Contributor

@vramana vramana commented Jun 15, 2015

No description provided.


if (valA !== valB) {
return false;
}
}
Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

@emmenko
Copy link
Contributor

emmenko commented Jun 15, 2015

The file should be named shallowEquality.spec.js

@vramana
Copy link
Contributor Author

vramana commented Jun 15, 2015

@emmenko Okay.Sorry I didn't notice it.

@emmenko
Copy link
Contributor

emmenko commented Jun 15, 2015

Np :)

describe('shallowEqualScalar', () => {
it('should compare the given arguments shallowly', () => {

expect(shallowEqualScalar(null, undefined)).toBe(false);
Copy link
Contributor

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', () => {
Copy link
Contributor Author

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?

Copy link
Contributor

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};
Copy link
Contributor

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.

@vramana
Copy link
Contributor Author

vramana commented Jun 16, 2015

@gaearon Can you take a look now ?

@ooflorent
Copy link
Contributor

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;
}

Copy link
Contributor

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?

@emmenko
Copy link
Contributor

emmenko commented Jun 16, 2015

@ooflorent 👍

@vramana
Copy link
Contributor Author

vramana commented Jun 16, 2015

@ooflorent Done. Anything else?

gaearon added a commit that referenced this pull request Jun 16, 2015
@gaearon gaearon merged commit 379ea8b into reduxjs:master Jun 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants