From b2fbc1269744c02a12fc3a0b201657cd77f03a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81abucki?= Date: Fri, 23 Jan 2026 16:24:46 +0100 Subject: [PATCH 1/2] fix:solution 2 --- src/restoreNames.test.js | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/restoreNames.test.js b/src/restoreNames.test.js index 6310350..0365db2 100644 --- a/src/restoreNames.test.js +++ b/src/restoreNames.test.js @@ -1,10 +1,48 @@ 'use strict'; +const { ExportConflictException } = require('@aws-sdk/client-dynamodb'); + describe('restoreNames', () => { - // const { restoreNames } = require('./restoreNames'); + const { restoreNames } = require('./restoreNames'); + + it('should set the firstName from fullName when firstName is set as undefined ', () => { + const users = [ + { + firstName: undefined, + lastName: 'Holy', + fullName: 'Jack Holy', + }, + ] + + restoreNames(users); + + expect(users[0].firstName).toBe('Jack') + }); + + it('should set the firstName from fullName when firstName is not set as property ', () => { + const users = [ + { + lastName: 'Holy', + fullName: 'Jack Holy', + }, + ] + + restoreNames(users); + + expect(users[0].firstName).toBe('Jack') + }); - it('should ', () => { + it('should keep the firstName when firstName has a different value than fullName', () => { + const users = [ + { firstName: 'Jack', + lastName: 'Holy', + fullName: 'John Holy', + }, + ] + + restoreNames(users); + expect(users[0].firstName).toBe('Jack') }); // write tests here From c758794f89742afd2f653dac474a3328e0e00a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81abucki?= Date: Fri, 23 Jan 2026 16:27:02 +0100 Subject: [PATCH 2/2] fix:solution 3 --- src/restoreNames.test.js | 52 +++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/restoreNames.test.js b/src/restoreNames.test.js index 0365db2..33f32e3 100644 --- a/src/restoreNames.test.js +++ b/src/restoreNames.test.js @@ -1,49 +1,51 @@ 'use strict'; -const { ExportConflictException } = require('@aws-sdk/client-dynamodb'); - describe('restoreNames', () => { const { restoreNames } = require('./restoreNames'); - it('should set the firstName from fullName when firstName is set as undefined ', () => { - const users = [ - { - firstName: undefined, - lastName: 'Holy', - fullName: 'Jack Holy', - }, - ] - - restoreNames(users); + it(`should set the firstName from fullName when firstName is undefined `, + () => { + const users = [ + { + firstName: undefined, + lastName: 'Holy', + fullName: 'Jack Holy', + }, + ]; - expect(users[0].firstName).toBe('Jack') - }); + restoreNames(users); + + expect(users[0].firstName).toBe('Jack'); + }); - it('should set the firstName from fullName when firstName is not set as property ', () => { + it(`should set the firstName from fullName when firstName + is not set as property`, + () => { const users = [ { lastName: 'Holy', fullName: 'Jack Holy', }, - ] - + ]; + restoreNames(users); - expect(users[0].firstName).toBe('Jack') + expect(users[0].firstName).toBe('Jack'); }); - it('should keep the firstName when firstName has a different value than fullName', () => { + it(`should keep the firstName when firstName has a different + value than fullName`, + () => { const users = [ - { firstName: 'Jack', + { + firstName: 'Jack', lastName: 'Holy', fullName: 'John Holy', }, - ] - + ]; + restoreNames(users); - expect(users[0].firstName).toBe('Jack') + expect(users[0].firstName).toBe('Jack'); }); - - // write tests here });