-
Notifications
You must be signed in to change notification settings - Fork 39
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
Default to array #34
Default to array #34
Conversation
it('can create array if all keys are numbers', () => { | ||
const result = u.updateIn('a.1', 3, null); | ||
|
||
expect(result).to.eql({ a: [, 3] }); |
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 leaves the linter unhappy, but I am not sure how to test this. Creating a new array and setting a value at an index i
where i
is greater than array.length results in some an array with some elements missing (docs). This seems fine from an application level, but testing it in this way makes the linter unhappy.
Should I just disable the linter warnings for this line?
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.
does [undefined, 3]
pass?
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.
It doesn't.
This looks, good, once you get stuff passing can you rebase into a single commit and update the readme/changelog too? Thanks! |
2bd6ae6
to
c33ae8f
Compare
it('can create array if all keys are numbers', () => { | ||
const result = u.updateIn('a.1', 3, null); | ||
|
||
expect(result).to.eql({ a: [, 3] }); // eslint-disable-line no-sparse-arrays |
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.
I'm actually surprised that this is valid syntax. It's not pretty though. Another option would be:
expect(result.a[1]).to.eql(3);
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.
well, you'd also need to test that it is an array if you did that. You could also just use the 0 index. I'm good w/ any of these (including what you did)
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.
I'll do 0 index
c33ae8f
to
0b0f6dc
Compare
fixes #22