Skip to content

Solution#229

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

Solution#229
AlbinaAlbi wants to merge 2 commits intomate-academy:masterfrom
AlbinaAlbi:develop

Conversation

@AlbinaAlbi
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

This requires a couple of changes to make your tests more robust. You've done a great job testing that the correct callback is executed, but the tests should also confirm that the other callback is not executed. This is crucial for verifying the exclusive nature of an if/else statement.

For example, in your test where the condition is true, you can add this assertion:

expect(second).not.toHaveBeenCalled();

Similarly, for the false condition, you should assert that first was not called.

Making these additions will ensure that a faulty implementation that calls both callbacks won't pass your tests. Once you've added these checks, your solution will be ready!


✨ 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).toHaveBeenCalled();
expect(first).toHaveBeenCalled();

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 the first callback is executed. To make this test more complete, you should also add an assertion to ensure the second callback was not called. This confirms that only the intended code path is taken.

ifElse(condition, first, second);

expect(condition).toHaveBeenCalled();
expect(second).toHaveBeenCalled();

Choose a reason for hiding this comment

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

Excellent check! Just like in the previous test, it's important to also assert that the first callback was not executed in this scenario. This ensures the function's logic is correctly branching.

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'm happy to approve your solution. You've perfectly addressed the feedback from the last review by adding assertions to confirm that the alternative callback is not called when it shouldn't be. This change significantly strengthens your tests and ensures all requirements are fully covered. Great job!


✨ 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