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

Bugfix: Child id can be smaller than parent id #26

Merged

Conversation

jesusisao
Copy link
Contributor

@jesusisao jesusisao commented Dec 6, 2020

feature

This PR allows users to use smaller child id than parent id.
#27

how

Achieved by adding "__depth" key and using it in sorting.

before:

before

after:

after

I'm not good at English, so I'm sorry if it's rude

@DenQ
Copy link
Owner

DenQ commented Dec 9, 2020

@jesusisao can we cover the writeDepth a function with tests?

expect( node[key_parent] ).toBe(0);
expect( key_child in node ).toBe(true);
expect( node[key_child].length ).toBe(2);
expect( node[depthKeyName] ).toBe(0);
Copy link
Contributor Author

@jesusisao jesusisao Dec 10, 2020

Choose a reason for hiding this comment

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

@DenQ
I added a depth test like this

parent: 101 // bad id
}, {
id: 10,
parent: 102 // bad id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also added a test if it was an invalid list.
(To prevent the recursive function from going into an infinite loop)

@DenQ
Copy link
Owner

DenQ commented Dec 12, 2020

@jesusisao i will look soon. Thank you.

@DenQ DenQ merged commit 51d6819 into DenQ:master Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants