Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job setting up the tests for the ifElse function! You've done well to cover both the true and false conditions using mocks. However, this requires changes because there's a critical issue with how you're checking that a function was not called. Assertions like expect(second).not.toHaveBeenCalledTimes are syntactically incorrect and will always pass, even if the function was called, which makes the tests unreliable. To fix this, please change these assertions to expect(second).not.toHaveBeenCalled(). This is the correct way to verify that a mock function was not invoked. You'll find this issue in the tests for both the true and false conditions. Once you've corrected the assertions, your tests will be solid!
✨ 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
| second.mockRestore(); | ||
| }); | ||
|
|
||
| it('should return noting', () => { |
There was a problem hiding this comment.
There's a small typo in the test description. It should be 'nothing' instead of 'noting'.
| expect(ifElse(conditionTrue, first, second)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should pass first fuction if condition is true', () => { |
There was a problem hiding this comment.
There's a typo in the test description. It should be 'function' instead of 'fuction'.
src/ifElse.test.js
Outdated
|
|
||
| expect(conditionTrue).toHaveBeenCalledTimes(1); | ||
| expect(first).toHaveBeenCalledTimes(1); | ||
| expect(second).not.toHaveBeenCalledTimes; |
There was a problem hiding this comment.
This assertion is incorrect and will not work as expected. toHaveBeenCalledTimes is a function and must be called with an argument, like toHaveBeenCalledTimes(0). The simpler way to check if a function was not called is expect(second).not.toHaveBeenCalled().
| }); | ||
|
|
||
| // write tests here | ||
| it('should pass first fuction if condition is false', () => { |
There was a problem hiding this comment.
This test description is misleading and contains a typo. This test case verifies that the second function is called when the condition is false, not the first function. A clearer description would be something like 'should call second function if condition is false'.
src/ifElse.test.js
Outdated
| ifElse(conditionFalse, first, second); | ||
|
|
||
| expect(conditionFalse).toHaveBeenCalledTimes(1); | ||
| expect(first).not.toHaveBeenCalledTimes; |
There was a problem hiding this comment.
This assertion is also incorrect, similar to the one in the previous test. toHaveBeenCalledTimes needs to be called as a function. To check that the first function was not called, please use expect(first).not.toHaveBeenCalled().
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this update! I am approving your solution as you've successfully addressed the critical feedback from the previous review. Your tests now correctly use not.toHaveBeenCalled() and all functional requirements are met.
As a minor suggestion for the future, you could improve the clarity of your test descriptions in src/ifElse.test.js. For example, there's a small typo ('noting' instead of 'nothing') and one description that could more accurately describe which function is being tested. These are just small points to help make your tests even more readable. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| second.mockRestore(); | ||
| }); | ||
|
|
||
| it('should return noting', () => { |
There was a problem hiding this comment.
There's a small typo in the test description. It should probably be "nothing" instead of "noting".
| }); | ||
|
|
||
| // write tests here | ||
| it('should pass first fuction if condition is false', () => { |
There was a problem hiding this comment.
This test description seems a bit misleading. While the test itself is correct, the description says it should pass the "first function", but it actually verifies that the second function is called when the condition is false. Updating the description to something like "should call the second function if the condition is false" would make it clearer.
No description provided.