Skip to content

Created some tests for the function#338

Open
GeorgeSavostikov wants to merge 2 commits into
mate-academy:masterfrom
GeorgeSavostikov:develop
Open

Created some tests for the function#338
GeorgeSavostikov wants to merge 2 commits into
mate-academy:masterfrom
GeorgeSavostikov:develop

Conversation

@GeorgeSavostikov

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

This is a great start on the test suite, and you've covered the main scenarios well. However, I'm requesting a few changes to make the tests more robust.

In your tests 'should add firstName if it is missing' and 'should restore firstName for all users in the array', the assertions only check that the firstName property exists using .toBeDefined(). This is good, but it doesn't confirm that the correct value was set from the fullName property.

Please update these assertions to check for the specific expected value. For example:

// Instead of this:
expect(users[0].firstName).toBeDefined();

// Do this:
expect(users[0].firstName).toBe('Jack');

This change will ensure your tests are verifying the function's logic correctly. With these stronger assertions, the test suite will be much more reliable!


✨ 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 thread src/restoreNames.test.js Outdated
// write tests here
restoreNames([user]);

expect(user.firstName).toBeDefined();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This assertion is good, but it could be more specific. It verifies that the firstName property is now defined, but it doesn't check if it holds the correct value. Consider using toBe('Jack') to ensure the name is correctly restored from fullName.

Comment thread src/restoreNames.test.js Outdated
Comment on lines +56 to +58
for (const user of users) {
expect(user.firstName).toBeDefined();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This loop correctly checks that the firstName property has been added to all users. However, it doesn't validate if the correct names were restored. It's better to check the specific values for each user to ensure the function is working as expected. For example:

expect(users[0].firstName).toBe('Jack');
expect(users[1].firstName).toBe('Mike');

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

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! Your solution is approved. You've successfully addressed the previous feedback by strengthening the test assertions, and the test suite is now very robust. It thoroughly covers all the requirements from the task description. The tests are well-written and correctly check all the necessary cases. 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