Skip to content

add tests#226

Open
RimmaBuzuluk wants to merge 2 commits intomate-academy:masterfrom
RimmaBuzuluk:master
Open

add tests#226
RimmaBuzuluk wants to merge 2 commits intomate-academy:masterfrom
RimmaBuzuluk:master

Conversation

@RimmaBuzuluk
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 correctly used mock functions to verify the main conditional logic. However, the tests are missing a couple of key requirements from the task description, so some changes are needed before this can be approved.

Specifically, your tests need to verify two more things:

  1. No return value: The ifElse function should not return a value. Please add an assertion to confirm its result is undefined.
  2. No arguments for callbacks: The tests should ensure that the condition, first, and second functions are called with no arguments. You can check this by using toHaveBeenCalledWith() on your mocks.

Once you add these assertions, your tests will fully cover all the requirements. Let me know if you have any questions!


✨ 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

@@ -1,11 +1,30 @@
'use strict';

describe('ifElse', () => {

Choose a reason for hiding this comment

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

Your tests cover the callback execution logic well. However, the task description mentions that 'No result is expected from isElse function'. Could you add a separate test case to confirm that ifElse returns undefined?


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 asserts that the condition function was called. To be more thorough and meet all requirements, you should also verify that it was called with no arguments. You can achieve this with expect(condition).toHaveBeenCalledWith(). The same applies to the first and second callbacks when they are executed.

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 adding the test to verify that ifElse returns undefined! We're very close to finishing this task.

However, one key requirement is not yet met. The tests need to verify that the condition, first, and second callback functions are called with no arguments. Your current tests use .toHaveBeenCalled(), which only checks if the function was called, but not what it was called with.

Please update your assertions to use .toHaveBeenCalledWith() to ensure no arguments are passed to the callbacks. This will fully satisfy the task requirements.


✨ 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

Comment on lines +13 to +14
expect(condition).toHaveBeenCalled();
expect(first).toHaveBeenCalled();

Choose a reason for hiding this comment

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

These assertions correctly check that the functions were called. However, the task requires ensuring they were called with no arguments. You can verify this by changing .toHaveBeenCalled() to .toHaveBeenCalledWith().


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.

Similar to the test case above, this should also verify that condition was called with no arguments. Please use .toHaveBeenCalledWith().


expect(condition).toHaveBeenCalled();
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.

Please also verify here that the second function was called with no arguments by using .toHaveBeenCalledWith().

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