Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
You've done a great job setting up the tests for the ifElse function and correctly verifying the main execution paths. However, I am requesting a couple of changes to make the tests more robust. Currently, your tests confirm that the correct callback is called, but they don't ensure the other callback is not called. For example, when the condition is true, you should also assert that the onFalse callback was not executed using expect(onFalseCallback).not.toHaveBeenCalled(). This will fully validate the exclusive if-else behavior. There is also a minor typo in one of the test descriptions that should be corrected for clarity. Once these assertions are added, your tests will be perfect!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/ifElse.test.js
Outdated
| it('should call second arg one time, if first arg return true', () => { | ||
| const f = jest.fn(); | ||
|
|
||
| ifElse(() => true, f, () => {}); |
There was a problem hiding this comment.
Great test! To make it more robust, consider also asserting that the second callback (the third argument) is not called. This ensures that the function doesn't accidentally execute both branches.
src/ifElse.test.js
Outdated
| }); | ||
|
|
||
| // write tests here | ||
| it('should call third arg one time, if first arg return true', () => { |
There was a problem hiding this comment.
There's a small typo in this test description. It should probably say "... if first arg return false" to match the test's logic.
src/ifElse.test.js
Outdated
| it('should call third arg one time, if first arg return true', () => { | ||
| const f = jest.fn(); | ||
|
|
||
| ifElse(() => false, () => {}, f); |
There was a problem hiding this comment.
Similar to the previous test, it's a good practice to also assert here that the first callback (the second argument) was not executed when the condition is false.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this iteration! You've successfully addressed all the feedback from the previous review. The tests for the ifElse function are now much more robust, ensuring that the correct callback is executed while also verifying that the other is not. This fully validates the function's logic, and your submission now meets all requirements perfectly. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.