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 correctly used mock functions to verify the main conditional logic. However, the tests are missing a couple of key requirements from the task description, so some changes are needed before this can be approved.
Specifically, your tests need to verify two more things:
- No return value: The
ifElsefunction should not return a value. Please add an assertion to confirm its result isundefined. - No arguments for callbacks: The tests should ensure that the
condition,first, andsecondfunctions are called with no arguments. You can check this by usingtoHaveBeenCalledWith()on your mocks.
Once you add these assertions, your tests will fully cover all the requirements. Let me know if you have any questions!
✨ 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
| @@ -1,11 +1,30 @@ | |||
| 'use strict'; | |||
|
|
|||
| describe('ifElse', () => { | |||
There was a problem hiding this comment.
Your tests cover the callback execution logic well. However, the task description mentions that 'No result is expected from isElse function'. Could you add a separate test case to confirm that ifElse returns undefined?
|
|
||
| ifElse(condition, first, second); | ||
|
|
||
| expect(condition).toHaveBeenCalled(); |
There was a problem hiding this comment.
This correctly asserts that the condition function was called. To be more thorough and meet all requirements, you should also verify that it was called with no arguments. You can achieve this with expect(condition).toHaveBeenCalledWith(). The same applies to the first and second callbacks when they are executed.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job adding the test to verify that ifElse returns undefined! We're very close to finishing this task.
However, one key requirement is not yet met. The tests need to verify that the condition, first, and second callback functions are called with no arguments. Your current tests use .toHaveBeenCalled(), which only checks if the function was called, but not what it was called with.
Please update your assertions to use .toHaveBeenCalledWith() to ensure no arguments are passed to the callbacks. This will fully satisfy the task requirements.
✨ 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
| expect(condition).toHaveBeenCalled(); | ||
| expect(first).toHaveBeenCalled(); |
There was a problem hiding this comment.
These assertions correctly check that the functions were called. However, the task requires ensuring they were called with no arguments. You can verify this by changing .toHaveBeenCalled() to .toHaveBeenCalledWith().
|
|
||
| ifElse(condition, first, second); | ||
|
|
||
| expect(condition).toHaveBeenCalled(); |
There was a problem hiding this comment.
Similar to the test case above, this should also verify that condition was called with no arguments. Please use .toHaveBeenCalledWith().
|
|
||
| expect(condition).toHaveBeenCalled(); | ||
| expect(first).not.toHaveBeenCalled(); | ||
| expect(second).toHaveBeenCalled(); |
There was a problem hiding this comment.
Please also verify here that the second function was called with no arguments by using .toHaveBeenCalledWith().
No description provided.