Skip to content

Solution#232

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

Solution#232
Julia2063 wants to merge 2 commits intomate-academy:masterfrom
Julia2063:develop

Conversation

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

You've done a great job setting up the tests for the ifElse function and correctly verifying the main execution paths. However, I am requesting a couple of changes to make the tests more robust. Currently, your tests confirm that the correct callback is called, but they don't ensure the other callback is not called. For example, when the condition is true, you should also assert that the onFalse callback was not executed using expect(onFalseCallback).not.toHaveBeenCalled(). This will fully validate the exclusive if-else behavior. There is also a minor typo in one of the test descriptions that should be corrected for clarity. Once these assertions are added, your tests will be perfect!


✨ 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

it('should call second arg one time, if first arg return true', () => {
const f = jest.fn();

ifElse(() => true, f, () => {});

Choose a reason for hiding this comment

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

Great test! To make it more robust, consider also asserting that the second callback (the third argument) is not called. This ensures that the function doesn't accidentally execute both branches.

});

// write tests here
it('should call third arg one time, if first arg return true', () => {

Choose a reason for hiding this comment

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

There's a small typo in this test description. It should probably say "... if first arg return false" to match the test's logic.

it('should call third arg one time, if first arg return true', () => {
const f = jest.fn();

ifElse(() => false, () => {}, f);

Choose a reason for hiding this comment

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

Similar to the previous test, it's a good practice to also assert here that the first callback (the second argument) was not executed when the condition is false.

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! You've successfully addressed all the feedback from the previous review. The tests for the ifElse function are now much more robust, ensuring that the correct callback is executed while also verifying that the other is not. This fully validates the function's logic, and your submission now meets all requirements perfectly. 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