Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/splitInteger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ function splitInteger(value, numberOfParts) {
return parts;
}

module.exports = splitInteger;
module.exports = { splitInteger };
31 changes: 24 additions & 7 deletions src/splitInteger.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
'use strict';

const splitInteger = require('./splitInteger');
const { splitInteger } = require('./splitInteger');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import uses destructuring which expects a named export, but the implementation uses a default export. Change to: 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]);
});
Loading