-
Notifications
You must be signed in to change notification settings - Fork 268
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
Conversation
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. |
You commits are not linked with your GitHub account . |
7a405f5
to
c84a0c5
Compare
I see what you mean. I've updated, should be OK now. |
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.
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.
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'); |
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.
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.
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.
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
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've updated this branch and amend tests to expect above error
1dbe61c
to
8ebaeac
Compare
#143