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
43 changes: 37 additions & 6 deletions src/splitInteger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,43 @@

const splitInteger = require('./splitInteger');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line has a syntax error - /** /**3**/ is malformed. It should be /** to start a block comment. This will cause a parse error when the file is loaded.


test(`should split a number into equal parts
if a value is divisible by a numberOfParts`, () => {});

test(`should return a part equals to a value
when splitting into 1 part`, () => {});
// Обов'язкові приклади з умови
test('should return [8] when splitting 8 into 1 part', () => {
expect(splitInteger(8, 1)).toEqual([8]);
});

test('should sort parts ascending if they are not equal', () => {});
test('should split 6 into 2 equal parts', () => {
expect(splitInteger(6, 2)).toEqual([3, 3]);
});

test('should split 17 into 4 ascending parts', () => {
expect(splitInteger(17, 4)).toEqual([4, 4, 4, 5]);
});

test('should split 32 into 6 ascending parts', () => {
expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 6]);
});

// Додаткові тести
test('should split a number into equal parts if divisible', () => {
expect(splitInteger(4, 2)).toEqual([2, 2]);
});

test('should return the value when splitting into 1 part', () => {
const value = 4;
const numberOfParts = 1;
const result = splitInteger(value, numberOfParts);

expect(result.length).toBe(numberOfParts);
expect(result[0]).toBe(value);
});

test('should sort parts ascending if they are not equal', () => {
expect(splitInteger(5, 4)).toEqual([1, 1, 1, 2]);
});

test('should add zeros if value < numberOfParts', () => {
expect(splitInteger(1, 4)).toEqual([0, 0, 0, 1]);
});

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