-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Develop #1068
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: develop
Are you sure you want to change the base?
Develop #1068
Changes from all commits
178e4ad
7ee7aa4
883bf21
3fd8d93
f0ae508
6efd841
84e5654
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 |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ name: Test | |
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| src/**/* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| 'use strict'; | ||
|
|
||
| /** | ||
| * @param {number} value | ||
| * @param {number} numberOfParts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,17 +5,34 @@ 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]) | ||
| expect(result).toHaveLength(2) | ||
| }); | ||
|
|
||
| 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(32, 6) | ||
|
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 required example |
||
| const diff = Math.max(...result) - Math.min(...result) | ||
|
|
||
| expect(result).toEqual([5, 5, 5, 5, 6, 6]) | ||
| expect(result).toHaveLength(6) | ||
| expect(diff).toBeLessThanOrEqual(1) | ||
|
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. Add a test for the required example test('should split 17 into 4 balanced parts', () => {
const result = splitInteger(17, 4)
expect(result).toEqual([4, 4, 4, 5])
expect(result).toHaveLength(4)
expect(Math.max(...result) - Math.min(...result)).toBeLessThanOrEqual(1)
})This addresses the missing required example from the description (HIGH priority). |
||
| }); | ||
|
|
||
| test('should add zeros if value < numberOfParts', () => { | ||
|
|
||
| const result = splitInteger(1, 2) | ||
|
|
||
| expect(result).toEqual([0, 1]) | ||
|
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. Add tests for the exact example cases required by the task description. The suite currently uses other values (10 and 1) but must include: |
||
| expect(result).toHaveLength(2) | ||
| }); | ||
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.
Add an explicit length assertion for this test. For example, after
const result = splitInteger(6, 2)addexpect(result).toHaveLength(2). This satisfies the requirement that the returned array contains exactlynumberOfPartselements (checklist item #1).