Skip to content
Open
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
13 changes: 12 additions & 1 deletion src/splitInteger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ const splitInteger = require('./splitInteger');

test(`should split a number into equal parts
if a value is divisible by a numberOfParts`, () => {
const actual = splitInteger(6, 2);
const expected = [3, 3];

expect(actual).toEqual(expected);
});

test(`should return a part equals to a value
when splitting into 1 part`, () => {
const actual = splitInteger(8, 1);
const expected = [8];

expect(actual).toEqual(expected);
});

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', () => {
const actual = splitInteger(2, 3);
const expected = [0, 1, 1];

expect(actual).toEqual(expected);
expect(actual).toContain(0);
});
Comment on lines 26 to 32
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your tests cover most of the examples from the requirements, but one is missing. Please review the task description and ensure all specified examples are tested.