tests v1#1025
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Decision: REQUEST_CHANGES — The tests are close, but there are critical gaps that prevent fully verifying the required behavior.
Critical issues to fix (blockers):
- In
src/splitInteger.test.js, after computingresult, add explicit assertions that every element is an integer and that the parts sum tovalue(requirement: output must contain only integers and sum equals original value):expect(result.every(Number.isInteger)).toBeTruthy();expect(result.reduce((a, b) => a + b, 0)).toBe(value);
- Test naming/input mismatches cause incorrect validation of stated behaviors:
- The test named “should sort parts ascending if they are not equal” currently calls
assertionFunc(5, 6)and assertstoContain(0). Either rename it to reflect zero-padding or change the assertions to check sorting explicitly (sorting is already covered insideassertionFunc). - The test labeled “should add zeros if value < numberOfParts” currently uses
assertionFunc(32, 6)andexpect(result).toEqual([5, 5, 5, 5, 6, 6]). Change the input to a zero-padding case like(5, 6)or rename the test to match the 32/6 example. - Ensure the example
splitInteger(17, 4)is covered withexpect(assertionFunc(17, 4)).toEqual([4, 4, 4, 5]);.
- The test named “should sort parts ascending if they are not equal” currently calls
Minor suggestions (non-blockers):
- In
.eslintrc.js, prefer'no-proto': 'off'over numeric0for clarity.
You’ve done well covering length, ascending order, and max–min difference; with the above fixes, the suite will fully validate the task requirements. Keep it up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| 'no-proto': 0, | ||
| strict: 0, | ||
| 'max-len': 0, | ||
| 'no-proto': 0 |
There was a problem hiding this comment.
Consider using the string severity form for clarity. Instead of 'no-proto': 0, prefer 'no-proto': 'off' so it's immediately clear to readers that the rule is disabled.
| const splitInteger = require('./splitInteger'); | ||
|
|
||
| const assertionFunc = (value, numberOfParts) => { | ||
| const result = splitInteger(value, numberOfParts); |
There was a problem hiding this comment.
Add checks that ensure every element is an integer and that the parts sum to the original value. The task requires the output array to contain only integers and, implicitly, that the sum of the parts equals value. Consider inserting assertions right after computing result:
expect(result.every(Number.isInteger)).toBeTruthy();
expect(result.reduce((a, b) => a + b, 0)).toBe(value);This will make the tests explicitly verify the integer-only requirement and correct partitioning.
| }); | ||
|
|
||
| test('should sort parts ascending if they are not equal', () => { | ||
| const result = assertionFunc(5, 6); |
There was a problem hiding this comment.
The test name says it should verify sorting ('should sort parts ascending if they are not equal') but the assertion uses assertionFunc(5, 6) and then checks toContain(0). The name and the assertion don't match. Either:
- Rename the test to reflect what it's asserting (e.g.
'should include zeros when value < numberOfParts'), or - Change the assertion to explicitly check sorting (although sorting is already checked inside
assertionFunc).
Right now the mismatch makes the test confusing.
| test('should sort parts ascending if they are not equal', () => { | ||
| const result = assertionFunc(5, 6); | ||
|
|
||
| expect(result).toContain(0); |
There was a problem hiding this comment.
This assertion expect(result).toContain(0); is valid when testing value < numberOfParts (some parts should be zero), but pairing it with the sorting test name is misleading. If you intend to test zero-padding, rename the test as suggested above and keep this assertion; otherwise change the input to test sorting specifically.
| }); | ||
|
|
||
| test('should add zeros if value < numberOfParts', () => { | ||
| const result = assertionFunc(32, 6); |
There was a problem hiding this comment.
The test labeled 'should add zeros if value < numberOfParts' calls assertionFunc(32, 6). That input has value > numberOfParts, so it does not test the zero-padding case. To test zero-padding, use an input where value < numberOfParts (for example assertionFunc(5, 6)). Alternatively, if you intended to test the example splitInteger(32, 6), rename the test to reflect that.
| test('should add zeros if value < numberOfParts', () => { | ||
| const result = assertionFunc(32, 6); | ||
|
|
||
| expect(result).toEqual([5, 5, 5, 5, 6, 6]); |
There was a problem hiding this comment.
This expectation expect(result).toEqual([5, 5, 5, 5, 6, 6]); matches the example from the description for splitInteger(32, 6), but because the test name says it checks zero-padding, it's misleading. Either change the test name to 'should split 32 into 6 parts as in example' or change the input to a zero-padding case. Also, ensure the integer-and-sum assertions suggested earlier are present so this example is fully validated.
| expect(maxNumber - minNumber).toBeLessThanOrEqual(1); | ||
|
|
||
| return result; | ||
| }; |
There was a problem hiding this comment.
Add a dedicated test for the example splitInteger(17, 4) === [4, 4, 4, 5] from the task description so all provided examples are covered. You can place it after the existing tests. Example:
test('should split 17 into 4 parts as in example', () => {
expect(assertionFunc(17, 4)).toEqual([4, 4, 4, 5]);
});This ensures the suite explicitly verifies that example.
No description provided.