Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Decision: Request Changes
Your tests are close, but they miss an explicit requirement: verifying that all callbacks are invoked with no arguments. The checklist states that condition, first, and second must be called without arguments, so you need assertions like toHaveBeenCalledWith() (with no params) for each relevant call.
Critical issues to fix:
- In src/ifElse.test.js, true-branch test: after
expect(condition).toHaveBeenCalledTimes(1), also assertexpect(condition).toHaveBeenCalledWith(); afterexpect(first).toHaveBeenCalledTimes(1), addexpect(first).toHaveBeenCalledWith(); and keepexpect(second).not.toHaveBeenCalled(). - In the false-branch test: add
expect(condition).toHaveBeenCalledWith()andexpect(second).toHaveBeenCalledWith(); and keepexpect(first).not.toHaveBeenCalled().
Why this matters: without these assertions, the tests don’t guarantee the callbacks are invoked with zero arguments, which is an explicit requirement and a core acceptance criterion.
Minor note: everything else looks solid—existence, branch coverage, call counts, and undefined return are well-checked. Once you add the no-argument assertions, this should fully meet the requirements. Keep up the good work!
✨ 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).toHaveBeenCalledTimes(1); | ||
| expect(first).toHaveBeenCalledTimes(1); | ||
| expect(second).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
The test asserts invocation counts for condition and first but does not verify they were called with no arguments. The requirements state: "Calls the condition callback with no arguments" and "No arguments are passed to first and second when they are called." Add assertions such as:
expect(condition).toHaveBeenCalledTimes(1);
expect(condition).toHaveBeenCalledWith(); // ensure no args passed
expect(first).toHaveBeenCalledTimes(1);
expect(first).toHaveBeenCalledWith(); // ensure no args passed
expect(second).not.toHaveBeenCalled();so this test checks both call counts and absence of arguments (checklist items).
| expect(condition).toHaveBeenCalledTimes(1); | ||
| expect(first).not.toHaveBeenCalled(); | ||
| expect(second).toHaveBeenCalledTimes(1); |
There was a problem hiding this comment.
The second-branch test checks call counts but does not assert that condition and second were called with no arguments. Per the requirements you must verify callbacks are invoked without arguments. Update this test to include assertions like:
expect(condition).toHaveBeenCalledTimes(1);
expect(condition).toHaveBeenCalledWith(); // ensure no args passed
expect(second).toHaveBeenCalledTimes(1);
expect(second).toHaveBeenCalledWith(); // ensure no args passed
expect(first).not.toHaveBeenCalled();This ensures mutual exclusivity and that no arguments were passed to the callbacks as required by the checklist.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your submission. Your tests thoroughly cover the required behavior: condition is called exactly once with no arguments, each branch invokes the correct callback (first for true, second for false) with no arguments, and the function returns undefined. The implementation matches these expectations and passes the logical requirements.
Note: CI is currently failing due to the workflow using Node 12 while the lint tooling requires Node ≥14. This is an environment issue, not a problem with your code. To unblock CI, update .github/workflows/test.yml to use node-version: '16.x' (or '18.x').
Minor improvement suggestion: if you intend truthy semantics, prefer if (condition()) rather than condition() === true, otherwise only a strict boolean true will trigger the first branch. Nicely done overall—clean tests and clear behavior.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.