Skip to content
Open
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
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
48 changes: 44 additions & 4 deletions src/splitInteger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
Loading