Skip to content
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

null check in nested key resolution #32

Merged
merged 5 commits into from
Nov 21, 2017

Conversation

cliewpaypal
Copy link
Contributor

@cliewpaypal cliewpaypal commented Nov 21, 2017

What:

Why: #31

How:

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

@kentcdodds
Copy link
Owner

The build is failing because we're not getting 100% code coverage with these changes. You could probably just add an item to this list where name: null and that should cover the new code 👍

@@ -105,7 +105,7 @@ const tests = {
},
'can handle objected with nested keys': {
input: [
[{name: {first: 'baz'}}, {name: {first: 'bat'}}, {name: {first: 'foo'}}],
[{name: {first: 'baz'}}, {name: {first: 'bat'}}, {}],
Copy link
Owner

Choose a reason for hiding this comment

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

Could you actually add another item to the array? This test is also ensuring that we filter out the foo item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh right gotcha.

src/index.js Outdated
@@ -251,7 +251,7 @@ function getItemValues(item, key) {
// handle nested keys
value = key
.split('.')
.reduce((itemObj, nestedKey) => itemObj[nestedKey], item)
.reduce((itemObj, nestedKey) => itemObj && itemObj[nestedKey] ? itemObj[nestedKey] : null, item)
Copy link
Owner

Choose a reason for hiding this comment

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

The second part of the && is unnecessary here

@codecov
Copy link

codecov bot commented Nov 21, 2017

Codecov Report

Merging #32 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #32   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         104    104           
  Branches       29     30    +1     
=====================================
  Hits          104    104
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a20725...9678b22. Read the comment docs.

@codecov
Copy link

codecov bot commented Nov 21, 2017

Codecov Report

Merging #32 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #32   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         104    104           
  Branches       29     30    +1     
=====================================
  Hits          104    104
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a20725...b02c4b9. Read the comment docs.

@kentcdodds kentcdodds merged commit fa8380b into kentcdodds:master Nov 21, 2017
@kentcdodds
Copy link
Owner

Thanks a bunch!

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.

2 participants