From beda967136b8c1a2a471e91ad1fe77afd514148b Mon Sep 17 00:00:00 2001 From: Alex <1inboxna@gmail.com> Date: Fri, 6 Nov 2026 14:54:14 +0200 Subject: [PATCH 1/2] Solution --- package.json | 2 +- src/splitInteger.test.js | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 068403cd..677968ef 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "init": "mate-scripts init", "start": "mate-scripts start", - "format": "prettier --ignore-path .prettierignore --write './src/**/*.js'", + "format": "prettier --ignore-path .prettierignore --write src/**/*.js", "lint": "npm run format && mate-scripts lint", "test:only": "mate-scripts test", "update": "mate-scripts update", diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 24003dd5..b41f205d 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -2,12 +2,29 @@ const splitInteger = require('./splitInteger'); -test(`should split a number into equal parts - if a value is divisible by a numberOfParts`, () => {}); +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, 4)).toEqual([2, 2, 2, 2]); + }, +); -test(`should return a part equals to a value - when splitting into 1 part`, () => {}); +test( + 'should return a part equals to a value ' + 'when splitting into 1 part', + () => { + expect(splitInteger(8, 1)).toEqual([8]); + expect(splitInteger(5, 1)).toEqual([5]); + }, +); -test('should sort parts ascending if they are not equal', () => {}); +test('should sort parts ascending if they are not equal', () => { + 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', () => {}); +test('should add zeros if value < numberOfParts', () => { + expect(splitInteger(2, 4)).toEqual([0, 0, 1, 1]); + expect(splitInteger(1, 3)).toEqual([0, 0, 1]); +}); From 3f6ed1a6c3780876d3f2670fa787e210e080966d Mon Sep 17 00:00:00 2001 From: Alex <1inboxna@gmail.com> Date: Fri, 6 Nov 2026 15:05:43 +0200 Subject: [PATCH 2/2] Add unit tests for splitInteger --- src/splitInteger.js | 2 +- src/splitInteger.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/splitInteger.js b/src/splitInteger.js index d3da7485..c57a28fd 100644 --- a/src/splitInteger.js +++ b/src/splitInteger.js @@ -20,4 +20,4 @@ function splitInteger(value, numberOfParts) { return parts; } -module.exports = splitInteger; +module.exports = { splitInteger }; diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index b41f205d..d1606048 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -1,6 +1,6 @@ 'use strict'; -const splitInteger = require('./splitInteger'); +const { splitInteger } = require('./splitInteger'); test( 'should split a number into equal parts ' +