Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Good job setting up the tests for the ifElse function. You've correctly covered the main conditional paths. However, a couple of changes are needed to fully meet the task requirements.
The requirements specify that all three callback functions (condition, first, and second) should be called with no arguments. Your tests currently use toHaveBeenCalled(), which only checks if a function was called. To make your tests more precise, please use toHaveBeenCalledWith() to assert that no arguments are passed.
Additionally, the requirements state that the ifElse function should not return a value. Please add an assertion to your tests to verify that the function's return value is undefined. These changes will ensure your tests are robust and fully validate the function's behavior.
✨ 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
|
|
||
| ifElse(condition, first, second); | ||
|
|
||
| expect(condition).toHaveBeenCalled(); |
There was a problem hiding this comment.
This correctly checks that the condition callback is invoked. The requirements state that callbacks should be run with no arguments. You can make your tests more precise by asserting this. For example, using toHaveBeenCalledWith() instead of toHaveBeenCalled() would verify that condition was called with no arguments. This principle also applies to the first and second callbacks in your other tests.
src/ifElse.test.js
Outdated
| test('should call only one callback depending on condition', () => { | ||
| const condition = jest.fn(() => true); | ||
| const first = jest.fn(); | ||
| const second = jest.fn(); | ||
|
|
||
| ifElse(condition, first, second); | ||
|
|
||
| expect(first).toHaveBeenCalledTimes(1); | ||
| expect(second).toHaveBeenCalledTimes(0); | ||
| }); |
There was a problem hiding this comment.
This test is correct, but its purpose is already covered by the tests on lines 16 and 27, where you check that one callback is called and the other is not. To make your tests more concise, you could enhance those existing tests with toHaveBeenCalledTimes(1) and remove this one.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this iteration! I am approving your solution as you've successfully addressed all the feedback from the previous review. Your tests are now much more precise, correctly asserting that the callbacks are called with no arguments and that the ifElse function returns undefined. All task requirements have been fully met. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.