From ac7419d5e4c1053044cc512b9233c9ffd4b41401 Mon Sep 17 00:00:00 2001 From: Mykyta Landar Date: Sat, 19 Sep 2026 21:03:49 +0200 Subject: [PATCH] solution --- src/splitInteger.test.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 24003dd5..5d0b3735 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -3,11 +3,26 @@ const splitInteger = require('./splitInteger'); test(`should split a number into equal parts - if a value is divisible by a numberOfParts`, () => {}); + if a value is divisible by a numberOfParts`, () => { + expect(splitInteger(6, 2)).toEqual([3, 3]); +}); test(`should return a part equals to a value - when splitting into 1 part`, () => {}); + when splitting into 1 part`, () => { + expect(splitInteger(8, 1)).toEqual([8]); +}); -test('should sort parts ascending if they are not equal', () => {}); +test('should sort parts ascending if they are not equal', () => { + const result = splitInteger(17, 4); -test('should add zeros if value < numberOfParts', () => {}); + for (let i = 0; i < result.length - 1; i++) { + expect(result[i]).toBeLessThanOrEqual(result[i + 1]); + } +}); + +test('should add zeros if value < numberOfParts', () => { + const result = splitInteger(2, 3); + + expect(result).toHaveLength(3); + expect(result).toContain(0); +});