From 9663c7260abc3218e3bb601fb6d7c008706be44b Mon Sep 17 00:00:00 2001 From: melarkkkk Date: Sat, 27 Dec 2025 08:40:01 +0100 Subject: [PATCH 1/2] add task solution --- src/splitInteger.test.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..8fe3adfe 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`, () => { - + expect(splitInteger(8, 1)).toEqual([8]); + expect(splitInteger(8, 2)).toEqual([4, 4]); + expect(splitInteger(8, 4)).toEqual([2, 2, 2, 2]); }); test(`should return a part equals to a value when splitting into 1 part`, () => { - + expect(splitInteger(8, 1)).toEqual([8]); + expect(splitInteger(16, 1)).toEqual([16]); + expect(splitInteger(24, 1)).toEqual([24]); }); test('should sort parts ascending if they are not equal', () => { - + expect(splitInteger(8, 5)).toEqual([1, 1, 2, 2, 2]); + expect(splitInteger(5, 2)).toEqual([2, 3]); + expect(splitInteger(10, 3)).toEqual([3, 3, 4]); }); test('should add zeros if value < numberOfParts', () => { - + expect(splitInteger(2, 5)).toEqual([0, 0, 0, 1, 1]); + expect(splitInteger(1, 2)).toEqual([0, 1]); + expect(splitInteger(3, 4)).toEqual([0, 1, 1, 1]); }); From 3d2b461aea5ea684f146fe00bf285d0fde83ef46 Mon Sep 17 00:00:00 2001 From: melarkkkk Date: Sat, 27 Dec 2025 08:51:29 +0100 Subject: [PATCH 2/2] feat: add additional cases to the existing tests --- src/splitInteger.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 8fe3adfe..5f5a64b9 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -4,6 +4,7 @@ const splitInteger = require('./splitInteger'); test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { + expect(splitInteger(6, 2)).toEqual([3, 3]); expect(splitInteger(8, 1)).toEqual([8]); expect(splitInteger(8, 2)).toEqual([4, 4]); expect(splitInteger(8, 4)).toEqual([2, 2, 2, 2]); @@ -18,8 +19,8 @@ test(`should return a part equals to a value test('should sort parts ascending if they are not equal', () => { expect(splitInteger(8, 5)).toEqual([1, 1, 2, 2, 2]); - expect(splitInteger(5, 2)).toEqual([2, 3]); - expect(splitInteger(10, 3)).toEqual([3, 3, 4]); + 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', () => { @@ -27,3 +28,4 @@ test('should add zeros if value < numberOfParts', () => { expect(splitInteger(1, 2)).toEqual([0, 1]); expect(splitInteger(3, 4)).toEqual([0, 1, 1, 1]); }); +