Skip to content

solution#221

Open
webEsperer wants to merge 2 commits intomate-academy:masterfrom
webEsperer:develop
Open

solution#221
webEsperer wants to merge 2 commits intomate-academy:masterfrom
webEsperer:develop

Conversation

@webEsperer
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 assert expect(condition).toHaveBeenCalledWith(); after expect(first).toHaveBeenCalledTimes(1), add expect(first).toHaveBeenCalledWith(); and keep expect(second).not.toHaveBeenCalled().
  • In the false-branch test: add expect(condition).toHaveBeenCalledWith() and expect(second).toHaveBeenCalledWith(); and keep expect(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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +17 to +19
expect(condition).toHaveBeenCalledTimes(1);
expect(first).toHaveBeenCalledTimes(1);
expect(second).not.toHaveBeenCalled();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +29 to +31
expect(condition).toHaveBeenCalledTimes(1);
expect(first).not.toHaveBeenCalled();
expect(second).toHaveBeenCalledTimes(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants