-
Notifications
You must be signed in to change notification settings - Fork 1.1k
js_split_integer #1023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
js_split_integer #1023
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,18 +4,26 @@ const splitInteger = require('./splitInteger'); | |
|
|
||
| test(`should split a number into equal parts | ||
| if a value is divisible by a numberOfParts`, () => { | ||
| const result = splitInteger(6, 2); | ||
|
|
||
| expect(result).toEqual([3, 3]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
| }); | ||
|
|
||
| test(`should return a part equals to a value | ||
| when splitting into 1 part`, () => { | ||
| const result = splitInteger(8, 1); | ||
|
|
||
| expect(result).toEqual([8]); | ||
| }); | ||
|
|
||
| test('should sort parts ascending if they are not equal', () => { | ||
| const result = splitInteger(17, 4); | ||
|
|
||
| expect(result).toEqual([4, 4, 4, 5]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good that you check a non-equal-parts example here. Also consider adding the additional example from the description |
||
| }); | ||
|
|
||
| test('should add zeros if value < numberOfParts', () => { | ||
| const result = splitInteger(3, 5); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The edge-case test for |
||
|
|
||
| expect(result).toEqual([0, 0, 1, 1, 1]); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test computes
resultforsplitInteger(6, 2)— good. Consider adding explicit property assertions here (instead of relying only on exact array equality) to verify the checklist items: array type, correct length, integer elements, sum equals input, sortedness, and max-min <= 1. For example:Adding these checks will ensure the test verifies the general properties from the task, not just one concrete output. (See checklist items 3.1–3.5.)