Skip to content

Commit 1d15df0

Browse files
committed
Solution
1 parent 88255ba commit 1d15df0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/splitInteger.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@ const splitInteger = require('./splitInteger');
55
test(`should split a number into equal parts
66
if a value is divisible by a numberOfParts`, () => {
77
expect(splitInteger(8, 1)).toEqual([8]);
8+
expect(splitInteger(6, 2)).toEqual([3, 3]);
89
expect(splitInteger(8, 2)).toEqual([4, 4]);
910
expect(splitInteger(9, 3)).toEqual([3, 3, 3]);
1011
expect(splitInteger(20, 4)).toEqual([5, 5, 5, 5]);
12+
expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]);
13+
expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]);
1114
});
1215

1316
test(`should return a part equals to a value
1417
when splitting into 1 part`, () => {
1518
expect(splitInteger(10, 1)).toEqual([10]);
1619
expect(splitInteger(0, 1)).toEqual([0]);
20+
expect(splitInteger(25, 1)).toEqual([25]);
21+
expect(splitInteger(7, 1)).toEqual([7]);
1722
});
1823

1924
test('should sort parts ascending if they are not equal', () => {
2025
expect(splitInteger(4, 2)).toEqual([2, 2]);
2126
expect(splitInteger(10, 3)).toEqual([3, 3, 4]);
2227
expect(splitInteger(14, 5)).toEqual([2, 3, 3, 3, 3]);
28+
expect(splitInteger(7, 3)).toEqual([2, 2, 3]);
2329
});
2430

2531
test('should add zeros if value < numberOfParts', () => {
2632
expect(splitInteger(4, 8)).toEqual([0, 0, 0, 0, 1, 1, 1, 1]);
33+
expect(splitInteger(3, 5)).toEqual([0, 0, 1, 1, 1]);
34+
expect(splitInteger(2, 4)).toEqual([0, 0, 1, 1]);
35+
expect(splitInteger(1, 3)).toEqual([0, 0, 1]);
2736
});

0 commit comments

Comments
 (0)