diff --git a/src/restoreNames.test.js b/src/restoreNames.test.js index 6310350..5e5a0dc 100644 --- a/src/restoreNames.test.js +++ b/src/restoreNames.test.js @@ -1,11 +1,46 @@ -'use strict'; +"use strict"; -describe('restoreNames', () => { - // const { restoreNames } = require('./restoreNames'); +describe("restoreNames", () => { + const { restoreNames } = require("./restoreNames"); - it('should ', () => { + it("should not return value", () => { + const users = [ + { + firstName: undefined, + lastName: "Holy", + fullName: "Jack Holy", + }, + { + lastName: "Adams", + fullName: "Mike Adams", + }, + ]; + const result = restoreNames(users); + expect(result).toBe(undefined); }); - // write tests here + it("should be a function", () => { + expect(restoreNames).toBeInstanceOf(Function); + }); + + it("firstName should be equal first part of fullName", () => { + const users = [ + { + firstName: undefined, + lastName: "Holy", + fullName: "Jack Holy", + }, + { + lastName: "Adams", + fullName: "Mike Adams", + }, + ]; + + restoreNames(users); + + users.forEach((item, index) => { + expect(item.firstName).toBe(item.fullName.split(" ")[0]); + }); + }); });