Skip to content

Add task solution#237

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

Add task solution#237
Igrik74 wants to merge 2 commits intomate-academy:masterfrom
Igrik74:develop

Conversation

@Igrik74
Copy link

@Igrik74 Igrik74 commented Jan 27, 2026

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

Great work on the test suite for the ifElse function! Your tests correctly cover the core logic of which callback gets executed. However, some changes are needed to fully meet the requirements. The task specifies that the condition, first, and second callbacks should be run with no arguments, and the current tests don't verify this. You can strengthen your assertions by using .toHaveBeenCalledWith() instead of just .toHaveBeenCalled(). For example, you can check that a function was called with no arguments like this: expect(myMockFunction).toHaveBeenCalledWith();. Please update your tests to include this check for all three callbacks.


✨ 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


ifElse(condition, first, second);

expect(condition).toHaveBeenCalledTimes(1);

Choose a reason for hiding this comment

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

This assertion correctly verifies that condition is called. The requirements also state that it should be run with no arguments. You can strengthen this test by also asserting it was called with no arguments, for example, by using .toHaveBeenCalledWith().

ifElse(condition, first, second);

it('should ', () => {
expect(first).toHaveBeenCalledTimes(1);

Choose a reason for hiding this comment

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

Good job checking that the first callback is executed. To make the test fully align with the implied behavior from the task description's example, you could also add an assertion that first is called with no arguments.


ifElse(condition, first, second);

expect(second).toHaveBeenCalledTimes(1);

Choose a reason for hiding this comment

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

This correctly tests that the second callback is run. The requirements explicitly state that second should be run 'with no arguments'. It would be best to add an assertion to verify this, for instance, with .toHaveBeenCalledWith().

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

Excellent work on this iteration! I am approving your solution. You've successfully addressed the feedback from the previous review by adding assertions to verify that all callbacks are executed without any arguments. Your test suite is now comprehensive, clear, and fully meets all the requirements of the task. Keep up the great work!


✨ 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