From a8c766e12a648ef79a2f0b6c075026f3944cfa7e Mon Sep 17 00:00:00 2001 From: Cirillo Negruzzi Date: Thu, 27 Nov 2025 16:18:16 +0100 Subject: [PATCH 1/3] Solution --- src/splitInteger.test.js | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index a610317d..9a0ae9e9 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -2,20 +2,35 @@ const splitInteger = require('./splitInteger'); -test(`should split a number into equal parts - if a value is divisible by a numberOfParts`, () => { - -}); - -test(`should return a part equals to a value - when splitting into 1 part`, () => { - -}); - -test('should sort parts ascending if they are not equal', () => { - -}); - -test('should add zeros if value < numberOfParts', () => { - +const testCases = [ + { + description: 'should split a number into equal parts if a value is divisible by a numberOfParts', + value: 10, + numberOfParts: 2, + expected: [5, 5], + }, + { + description: 'should return a part equals to a value when splitting into 1 part', + value: 3, + numberOfParts: 1, + expected: [3], + }, + { + description: 'should sort parts ascending if they are not equal', + value: 5, + numberOfParts: 3, + expected: [1, 2, 2], + }, + { + description: 'should add zeros if value < numberOfParts', + value: 2, + numberOfParts: 5, + expected: [0, 0, 0, 1, 1], + }, +]; + +testCases.forEach(({ description, value, numberOfParts, expected }) => { + test(description, () => { + expect(splitInteger(value, numberOfParts)).toEqual(expected); + }) }); From 409a4460c3ea3148dd4901285d4aafe6236cb299 Mon Sep 17 00:00:00 2001 From: Cirillo Negruzzi Date: Thu, 27 Nov 2025 16:24:42 +0100 Subject: [PATCH 2/3] added example data --- src/splitInteger.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 9a0ae9e9..00c2fad8 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -5,21 +5,21 @@ const splitInteger = require('./splitInteger'); const testCases = [ { description: 'should split a number into equal parts if a value is divisible by a numberOfParts', - value: 10, + value: 6, numberOfParts: 2, - expected: [5, 5], + expected: [3, 3], }, { description: 'should return a part equals to a value when splitting into 1 part', - value: 3, + value: 8, numberOfParts: 1, - expected: [3], + expected: [8], }, { description: 'should sort parts ascending if they are not equal', - value: 5, - numberOfParts: 3, - expected: [1, 2, 2], + value: 17, + numberOfParts: 4, + expected: [4, 4, 4, 5], }, { description: 'should add zeros if value < numberOfParts', From 7b6035ebdc497418f2c854d7f1e5b8c39e9d4878 Mon Sep 17 00:00:00 2001 From: Cirillo Negruzzi Date: Thu, 27 Nov 2025 16:28:47 +0100 Subject: [PATCH 3/3] rage-quit --- src/splitInteger.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 00c2fad8..a75975fe 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -21,6 +21,12 @@ const testCases = [ numberOfParts: 4, expected: [4, 4, 4, 5], }, + { + description: 'should sort parts ascending if they are not equal', + value: 32, + numberOfParts: 6, + expected: [5, 5, 5, 5, 6, 6], + }, { description: 'should add zeros if value < numberOfParts', value: 2,