diff --git a/package-lock.json b/package-lock.json index 33b23f7f..9dc71fde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "eslint": "^8.57.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", - "jest": "^24.5.0", + "jest": "^24.9.0", "prettier": "^3.3.2" } }, @@ -5651,6 +5651,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-24.9.0.tgz", "integrity": "sha512-YvkBL1Zm7d2B1+h5fHEOdyjCG+sGMz4f8D86/0HiqJ6MB4MnDc8FgP5vdWsGnemOQro7lnYo8UakZ3+5A0jxGw==", "dev": true, + "license": "MIT", "dependencies": { "import-local": "^2.0.0", "jest-cli": "^24.9.0" diff --git a/package.json b/package.json index 068403cd..69ecb9af 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "eslint": "^8.57.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", - "jest": "^24.5.0", + "jest": "^24.9.0", "prettier": "^3.3.2" }, "mateAcademy": { diff --git a/src/splitInteger.test.js b/src/splitInteger.test.js index 24003dd5..3a8abc7e 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -3,11 +3,51 @@ 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`, () => { + const result = splitInteger(12, 3); + + expect(result).toEqual([4, 4, 4]); +}); test(`should return a part equals to a value - when splitting into 1 part`, () => {}); + when splitting into 1 part`, () => { + const result = splitInteger(10, 1); + + expect(result).toEqual([10]); +}); + +test('should sort parts ascending if they are not equal', () => { + const result = splitInteger(10, 3); + + expect(result).toEqual([3, 3, 4]); +}); + +test('should add zeros if value < numberOfParts', () => { + const result = splitInteger(3, 10); + + expect(result).toEqual([0, 0, 0, 0, 0, 0, 0, 1, 1, 1]); +}); + +test('should return the value when splitting into 1 part', () => { + const result = splitInteger(8, 1); + + expect(result).toEqual([8]); +}); + +test('should split a number into equal parts', () => { + const result = splitInteger(6, 2); + + expect(result).toEqual([3, 3]); +}); + +test('should split into ascending parts when the result is not equal', () => { + const result = splitInteger(17, 4); + + expect(result).toEqual([4, 4, 4, 5]); +}); -test('should sort parts ascending if they are not equal', () => {}); +test('should distribute the remainder between several parts', () => { + const result = splitInteger(32, 6); -test('should add zeros if value < numberOfParts', () => {}); + expect(result).toEqual([5, 5, 5, 5, 6, 6]); +});