From abbede2ca734de83bd87b3fa74447f0edb097b87 Mon Sep 17 00:00:00 2001 From: Anna Nikiforova Date: Thu, 27 Nov 2025 23:40:40 +0400 Subject: [PATCH 1/2] Split integer solution --- src/splitInteger.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..53845b72 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -4,18 +4,26 @@ const splitInteger = require('./splitInteger'); test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { + const parts = splitInteger(6, 2); + expect(parts).toEqual([3, 3]); }); test(`should return a part equals to a value when splitting into 1 part`, () => { + const parts = splitInteger(8, 1); + expect(parts).toEqual([8]); }); test('should sort parts ascending if they are not equal', () => { + const parts = splitInteger(17, 4); + expect(parts).toEqual([4, 4, 4, 5]); }); test('should add zeros if value < numberOfParts', () => { + const parts = splitInteger(3, 6); + expect(parts).toEqual([0, 0, 0, 1, 1, 1]); }); From b92a290305ec076c9a4ad69128acd197112ba99f Mon Sep 17 00:00:00 2001 From: Anna Nikiforova Date: Thu, 27 Nov 2025 23:52:53 +0400 Subject: [PATCH 2/2] Fix the issues --- src/splitInteger.test.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 53845b72..fdcbfdae 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -11,19 +11,14 @@ test(`should split a number into equal parts test(`should return a part equals to a value when splitting into 1 part`, () => { - const parts = splitInteger(8, 1); - - expect(parts).toEqual([8]); + expect(splitInteger(8, 1)).toEqual([8]); }); test('should sort parts ascending if they are not equal', () => { - const parts = splitInteger(17, 4); - - expect(parts).toEqual([4, 4, 4, 5]); + expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]); + expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]); }); test('should add zeros if value < numberOfParts', () => { - const parts = splitInteger(3, 6); - - expect(parts).toEqual([0, 0, 0, 1, 1, 1]); + expect(splitInteger(3, 6)).toEqual([0, 0, 0, 1, 1, 1]); });