Skip to content

Develop#245

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

Develop#245
Vitaligna wants to merge 2 commits intomate-academy:masterfrom
Vitaligna:develop

Conversation

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

Good job setting up the tests for the ifElse function. You've correctly covered the main conditional paths. However, a couple of changes are needed to fully meet the task requirements.

The requirements specify that all three callback functions (condition, first, and second) should be called with no arguments. Your tests currently use toHaveBeenCalled(), which only checks if a function was called. To make your tests more precise, please use toHaveBeenCalledWith() to assert that no arguments are passed.

Additionally, the requirements state that the ifElse function should not return a value. Please add an assertion to your tests to verify that the function's return value is undefined. These changes will ensure your tests are robust and fully validate the function's behavior.


✨ 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();

Choose a reason for hiding this comment

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

This correctly checks that the condition callback is invoked. The requirements state that callbacks should be run with no arguments. You can make your tests more precise by asserting this. For example, using toHaveBeenCalledWith() instead of toHaveBeenCalled() would verify that condition was called with no arguments. This principle also applies to the first and second callbacks in your other tests.

Comment on lines +38 to +47
test('should call only one callback depending on condition', () => {
const condition = jest.fn(() => true);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

expect(first).toHaveBeenCalledTimes(1);
expect(second).toHaveBeenCalledTimes(0);
});

Choose a reason for hiding this comment

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

This test is correct, but its purpose is already covered by the tests on lines 16 and 27, where you check that one callback is called and the other is not. To make your tests more concise, you could enhance those existing tests with toHaveBeenCalledTimes(1) and remove this one.

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 as you've successfully addressed all the feedback from the previous review. Your tests are now much more precise, correctly asserting that the callbacks are called with no arguments and that the ifElse function returns undefined. All task requirements have been fully met. 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