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.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 24003dd5..d1606048 100644 --- a/src/splitInteger.test.js +++ b/src/splitInteger.test.js @@ -1,13 +1,30 @@ 'use strict'; -const splitInteger = require('./splitInteger'); +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]); +});