Skip to content

solution#231

Open
VasylPylypchynets wants to merge 1 commit intomate-academy:masterfrom
VasylPylypchynets:develop
Open

solution#231
VasylPylypchynets wants to merge 1 commit intomate-academy:masterfrom
VasylPylypchynets:develop

Conversation

@VasylPylypchynets
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 work on this! Your solution correctly implements the core logic for the ifElse function, and your tests effectively cover both the true and false paths. I am approving your submission.

To make your tests even more robust in the future, consider verifying all aspects of the requirements. For instance, you could assert that the callbacks are called with no arguments using toHaveBeenCalledWith(). Additionally, a test to confirm that the ifElse function itself returns undefined would fully cover the requirements.

These are points for improvement, but your current implementation successfully meets the core goals. 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

it(`should call 'first' if 'condition' returns true`, () => {
condition.mockReturnValue(true);
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 correctly verifies that the first callback is executed. The requirements also state that callbacks should be run 'with no arguments'. To make this test more precise, you could also check that both condition and first were called without any arguments using toHaveBeenCalledWith().

condition.mockReturnValue(false);
ifElse(condition, first, second);
expect(first).not.toHaveBeenCalled();
expect(second).toHaveBeenCalled();

Choose a reason for hiding this comment

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

This check is correct. To fully align with the requirements, consider also asserting that both the condition and second callbacks were called without arguments.

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