Skip to content

test: add test for get-unique-words #149

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
Oct 28, 2019

Conversation

ChristieRobson
Copy link
Contributor

@TheSTL
Copy link
Member

TheSTL commented Oct 26, 2019

Hi @ChristieRobson your commits are not displayed, setup local git properly and push again.

@ChristieRobson
Copy link
Contributor Author

Hi @ChristieRobson your commits are not displayed, setup local git properly and push again.

@TheSTL similar to the other PR I am unsure what you need me to set up differently. I can see one commit and 1 file change in this PR. I can also see them if viewing this PR without being logged into my account so I don't think there is a permissions issue. Please advise.

image

@TheSTL
Copy link
Member

TheSTL commented Oct 26, 2019

You commits are not linked with your GitHub account .
For more details go to this link https://help.github.com/en/github/committing-changes-to-your-project/why-are-my-commits-linked-to-the-wrong-user
I think it will work https://stackoverflow.com/questions/26004587/git-commits-are-not-getting-linked-with-my-github-account

@ChristieRobson ChristieRobson force-pushed the test/get-unique-words branch 2 times, most recently from 7a405f5 to c84a0c5 Compare October 26, 2019 12:43
@ChristieRobson
Copy link
Contributor Author

You commits are not linked with your GitHub account .
For more details go to this link https://help.github.com/en/github/committing-changes-to-your-project/why-are-my-commits-linked-to-the-wrong-user
I think it will work https://stackoverflow.com/questions/26004587/git-commits-are-not-getting-linked-with-my-github-account

I see what you mean. I've updated, should be OK now.

Copy link
Member

@ashokdey ashokdey left a comment

Choose a reason for hiding this comment

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

Hello @ChristieRobson, I appreciate your efforts, however, I feel when you write tests your mind should work like "How I can break this function 👿 "!

I can see there is a good scope of adding more unit tests to this function. Few hints:

  • check for the length of the array returned
  • check passing an empty array
  • try passing null
  • etc..

PS: do star the repo if you liked it.

Comment on lines 37 to 60
it('passing an empty Trie will throw an error ', () => {
const trie = new Trie();
expect(() => {
getUniqueWords(trie);
}).toThrow('Cannot read property \'0\' of undefined');
});

it('passing an empty array will throw an error ', () => {
expect(() => {
getUniqueWords([]);
}).toThrow('Cannot read property \'0\' of undefined');
});

it('passing null will throw an error ', () => {
expect(() => {
getUniqueWords([]);
}).toThrow('Cannot read property \'0\' of undefined');
});


it('passing an array not in a Trie will throw an error ', () => {
expect(() => {
getUniqueWords(['bed', 'ball', 'apple']);
}).toThrow('Cannot read property \'0\' of undefined');
Copy link
Member

@ashokdey ashokdey Oct 26, 2019

Choose a reason for hiding this comment

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

Thanks for highlighting, this case was something not handled by me in the implementation. Let me add an error message.

Accordingly, you will have to take a pull of master and run the tests again, these selected tests will fail and you will just have to update the test cases with the result.

Thank you again.

Copy link
Member

Choose a reason for hiding this comment

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

Code will throw "Invalid argument: Root of Trie is required", please make changes accordingly. Do not forget to take the pull of master: git pull origin master

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've updated this branch and amend tests to expect above error

@ashokdey ashokdey merged commit 37fd3af into knaxus:master Oct 28, 2019
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.

3 participants