Skip to content

Commit 433d074

Browse files
committed
Tests for splitInteger function
1 parent 883bf21 commit 433d074

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/splitInteger.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ const splitInteger = require('./splitInteger');
44

55
test(`should split a number into equal parts
66
if a value is divisible by a numberOfParts`, () => {
7+
const result = splitInteger(6, 2);
78

9+
expect(result).toStrictEqual([3, 3]);
810
});
911

1012
test(`should return a part equals to a value
1113
when splitting into 1 part`, () => {
14+
const result = splitInteger(8, 1);
1215

16+
expect(result).toStrictEqual([8]);
1317
});
1418

1519
test('should sort parts ascending if they are not equal', () => {
20+
const result = splitInteger(17, 4);
1621

22+
expect(result).toStrictEqual([4, 4, 4, 5]);
1723
});
1824

1925
test('should add zeros if value < numberOfParts', () => {
26+
const result = splitInteger(6, 8);
2027

28+
expect(result).toStrictEqual([0, 0, 1, 1, 1, 1, 1, 1]);
2129
});

0 commit comments

Comments
 (0)