Skip to content

Add solution#334

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

Add solution#334
dminikulin wants to merge 2 commits intomate-academy:masterfrom
dminikulin:develop

Conversation

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

Excellent work on implementing the tests for the restoreNames function! You've successfully covered the required scenarios for users with missing or undefined first names. Since all core requirements are met, I am approving your solution. To make your test suite even more robust, I'd recommend adding a test case for users who already have a valid firstName. This would confirm that your function doesn't unintentionally modify correct data, which is a great practice for ensuring code stability.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines 3 to 42
describe('restoreNames', () => {
// const { restoreNames } = require('./restoreNames');
const { restoreNames } = require('./restoreNames');

it('should ', () => {
it(`should restore the first name for entry that
is missing the firstName property`, () => {
const users = [
{
lastName: 'Adams',
fullName: 'Mike Adams',
},
];

restoreNames(users);

expect(users).toEqual([{
firstName: 'Mike',
lastName: 'Adams',
fullName: 'Mike Adams',
}]);
});

// write tests here
it(`should restore the first name for entry that
has firstName property with 'undefined' value`, () => {
const users = [
{
firstName: undefined,
lastName: 'Holy',
fullName: 'Jack Holy',
},
];

restoreNames(users);

expect(users).toEqual([{
firstName: 'Jack',
lastName: 'Holy',
fullName: 'Jack Holy',
}]);
});
});

Choose a reason for hiding this comment

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

These test cases are great for covering the scenarios where a firstName needs to be restored. It would be a good idea to also add a test case for users who already have a firstName. This would verify that your function doesn't modify entries that are already correct.

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