Skip to content

solution#242

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

solution#242
Vitalii120296 wants to merge 2 commits intomate-academy:masterfrom
Vitalii120296:develop

Conversation

@Vitalii120296
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 setting up the tests for the ifElse function! You've done well to cover both the true and false conditions using mocks. However, this requires changes because there's a critical issue with how you're checking that a function was not called. Assertions like expect(second).not.toHaveBeenCalledTimes are syntactically incorrect and will always pass, even if the function was called, which makes the tests unreliable. To fix this, please change these assertions to expect(second).not.toHaveBeenCalled(). This is the correct way to verify that a mock function was not invoked. You'll find this issue in the tests for both the true and false conditions. Once you've corrected the assertions, your tests will be solid!


✨ 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

second.mockRestore();
});

it('should return noting', () => {

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 the test description. It should be 'nothing' instead of 'noting'.

expect(ifElse(conditionTrue, first, second)).toBeUndefined();
});

it('should pass first fuction if condition is true', () => {

Choose a reason for hiding this comment

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

There's a typo in the test description. It should be 'function' instead of 'fuction'.


expect(conditionTrue).toHaveBeenCalledTimes(1);
expect(first).toHaveBeenCalledTimes(1);
expect(second).not.toHaveBeenCalledTimes;

Choose a reason for hiding this comment

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

This assertion is incorrect and will not work as expected. toHaveBeenCalledTimes is a function and must be called with an argument, like toHaveBeenCalledTimes(0). The simpler way to check if a function was not called is expect(second).not.toHaveBeenCalled().

});

// write tests here
it('should pass first fuction if condition is false', () => {

Choose a reason for hiding this comment

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

This test description is misleading and contains a typo. This test case verifies that the second function is called when the condition is false, not the first function. A clearer description would be something like 'should call second function if condition is false'.

ifElse(conditionFalse, first, second);

expect(conditionFalse).toHaveBeenCalledTimes(1);
expect(first).not.toHaveBeenCalledTimes;

Choose a reason for hiding this comment

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

This assertion is also incorrect, similar to the one in the previous test. toHaveBeenCalledTimes needs to be called as a function. To check that the first function was not called, please use expect(first).not.toHaveBeenCalled().

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 the critical feedback from the previous review. Your tests now correctly use not.toHaveBeenCalled() and all functional requirements are met.

As a minor suggestion for the future, you could improve the clarity of your test descriptions in src/ifElse.test.js. For example, there's a small typo ('noting' instead of 'nothing') and one description that could more accurately describe which function is being tested. These are just small points to help make your tests even more readable. 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

second.mockRestore();
});

it('should return noting', () => {

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 the test description. It should probably be "nothing" instead of "noting".

});

// write tests here
it('should pass first fuction if condition is false', () => {

Choose a reason for hiding this comment

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

This test description seems a bit misleading. While the test itself is correct, the description says it should pass the "first function", but it actually verifies that the second function is called when the condition is false. Updating the description to something like "should call the second function if the condition is false" would make it clearer.

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