Skip to content

solution_1#228

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

solution_1#228
andriy-fesych wants to merge 2 commits intomate-academy:masterfrom
andriy-fesych:develop

Conversation

@andriy-fesych
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

Great job writing the tests for the ifElse function! You've correctly covered the main logic for both true and false conditions. However, a couple of changes are needed to fully meet the project requirements.

First, the requirements state that the ifElse function should return no result. Your test suite is missing a check to verify that the function's return value is undefined. You can add an assertion like expect(ifElse(condition, first, second)).toBeUndefined(); to cover this.

Additionally, while you correctly check that the callbacks are called, the tests should also verify they are called with no arguments. You can make your tests more precise by using toHaveBeenCalledWith() instead of toHaveBeenCalled().


✨ 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

});

// write tests here
it('should execute 1st callback if condition is true', () => {

Choose a reason for hiding this comment

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

It's a good practice to group all assertions for a single scenario into one test. You could combine this test with the one on line 24 to create a single, comprehensive test for what happens when the condition is true. The same principle applies to the tests for the false condition.


ifElse(condition, first, second);

expect(first).toHaveBeenCalled();

Choose a reason for hiding this comment

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

This is a good check. To fully align with the requirements, the tests should also verify that the callbacks are executed with no arguments. The toHaveBeenCalledWith() matcher can help you with this. This applies to both the first and second callbacks in their respective test cases.

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 update! I am approving your solution as you've successfully addressed all the previous feedback, and your tests now thoroughly cover all the requirements for the ifElse function. I have just one minor suggestion for future reference: in src/ifElse.test.js, the initial call to ifElse is redundant because the function is called again within the expect statement. You can safely remove that first call to make the test a bit cleaner. This is just a small point, and the code is in great shape. Well done!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

return true;
};

ifElse(condition, first, second);

Choose a reason for hiding this comment

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

This call to ifElse is redundant. The function is called again within the expect statement on line 33, which is sufficient to test the return value. You can safely remove this line to make the test more concise.

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