From 0c765c35a9cc6edbe126b584cdc7440efa10990f Mon Sep 17 00:00:00 2001 From: Dmytro Nikulin Date: Wed, 25 Feb 2026 12:08:04 +0200 Subject: [PATCH 1/3] Add 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..76eef028 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 result = splitInteger(6, 2); + expect(result).toHaveLength(2); }); test(`should return a part equals to a value when splitting into 1 part`, () => { + const result = splitInteger(8, 1); + expect(result).toEqual([8]); }); test('should sort parts ascending if they are not equal', () => { + const result = splitInteger(32, 6); + expect(result).toEqual([5, 5, 5, 5, 6, 6]); }); test('should add zeros if value < numberOfParts', () => { + const result = splitInteger(3, 5); + expect(result).toEqual([1, 1, 1, 0, 0]); }); From 3a3f8df7f3393e9b9f2fdccf362243b54a250868 Mon Sep 17 00:00:00 2001 From: Dmytro Nikulin Date: Wed, 25 Feb 2026 12:08:38 +0200 Subject: [PATCH 2/3] Add solution --- src/splitInteger.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 76eef028..480040ce 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -25,5 +25,5 @@ test('should sort parts ascending if they are not equal', () => { test('should add zeros if value < numberOfParts', () => { const result = splitInteger(3, 5); - expect(result).toEqual([1, 1, 1, 0, 0]); + expect(result).toEqual([0, 0, 1, 1, 1]); }); From 13b06b5ff14d85829f532dab26fe9dbe6f63fc77 Mon Sep 17 00:00:00 2001 From: Dmytro Nikulin Date: Wed, 25 Feb 2026 12:11:56 +0200 Subject: [PATCH 3/3] One test improved, one test added --- src/splitInteger.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 480040ce..07791d6c 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -6,7 +6,7 @@ test(`should split a number into equal parts if a value is divisible by a numberOfParts`, () => { const result = splitInteger(6, 2); - expect(result).toHaveLength(2); + expect(result).toEqual([3, 3]); }); test(`should return a part equals to a value @@ -16,6 +16,12 @@ test(`should return a part equals to a value expect(result).toEqual([8]); }); +test('should sort parts ascending if they are not equal', () => { + const result = splitInteger(17, 4); + + expect(result).toEqual([4, 4, 4, 5]); +}); + test('should sort parts ascending if they are not equal', () => { const result = splitInteger(32, 6);