Skip to content

tests v1#1025

Open
reb0rned wants to merge 4 commits into
mate-academy:mainfrom
reb0rned:main
Open

tests v1#1025
reb0rned wants to merge 4 commits into
mate-academy:mainfrom
reb0rned:main

Conversation

@reb0rned
Copy link
Copy Markdown

@reb0rned reb0rned commented Oct 6, 2025

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

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 computing result, add explicit assertions that every element is an integer and that the parts sum to value (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 asserts toContain(0). Either rename it to reflect zero-padding or change the assertions to check sorting explicitly (sorting is already covered inside assertionFunc).
    • The test labeled “should add zeros if value < numberOfParts” currently uses assertionFunc(32, 6) and expect(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 with expect(assertionFunc(17, 4)).toEqual([4, 4, 4, 5]);.

Minor suggestions (non-blockers):

  • In .eslintrc.js, prefer 'no-proto': 'off' over numeric 0 for 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread .eslintrc.js Outdated
'no-proto': 0,
strict: 0,
'max-len': 0,
'no-proto': 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/splitInteger.test.js
const splitInteger = require('./splitInteger');

const assertionFunc = (value, numberOfParts) => {
const result = splitInteger(value, numberOfParts);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/splitInteger.test.js
});

test('should sort parts ascending if they are not equal', () => {
const result = assertionFunc(5, 6);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/splitInteger.test.js
test('should sort parts ascending if they are not equal', () => {
const result = assertionFunc(5, 6);

expect(result).toContain(0);
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 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.

Comment thread src/splitInteger.test.js Outdated
});

test('should add zeros if value < numberOfParts', () => {
const result = assertionFunc(32, 6);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/splitInteger.test.js Outdated
test('should add zeros if value < numberOfParts', () => {
const result = assertionFunc(32, 6);

expect(result).toEqual([5, 5, 5, 5, 6, 6]);
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 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.

Comment thread src/splitInteger.test.js
expect(maxNumber - minNumber).toBeLessThanOrEqual(1);

return result;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants