Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -9,7 +9,7 @@
"test:only": "mate-scripts test",
"update": "mate-scripts update",
"postinstall": "npm run update",
"test": "npm run lint && npm run test:only"
"test": "jest"
},
"author": "Mate academy",
"license": "GPL-3.0",
Expand Down
16 changes: 10 additions & 6 deletions src/splitInteger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
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 actual = splitInteger(6, 2);
  expect(actual).toEqual([3, 3]);
});

test(`should return a part equals to a value
when splitting into 1 part`, () => {

  when splitting into 1 part`, () => {
  const actual = splitInteger(8, 1);
  expect(actual).toEqual([8]);
});

test('should sort parts ascending if they are not equal', () => {

  const actual = splitInteger(17, 4);
  expect(actual).toEqual([4, 4, 4, 5]);
});

test('should add zeros if value < numberOfParts', () => {

  const actual = splitInteger(2, 3);
  expect(actual).toEqual([0, 1, 1]);
});