Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| 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', | ||
| }]); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
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.
No description provided.