-
Notifications
You must be signed in to change notification settings - Fork 1.1k
done #1016
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?
done #1016
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,9 +4,7 @@ module.exports = { | |
| jest: true | ||
| }, | ||
| rules: { | ||
| 'no-proto': 0, | ||
| strict: 0, | ||
| 'max-len': 0, | ||
| 'no-proto': 0 | ||
|
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. Consider using the string form for the rule level for readability and adding a short justification comment if disabling 'no-proto': 'off' // disabled to allow use of __proto__ in test helpers / legacy interopUsing |
||
| }, | ||
| plugins: ['jest'] | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [20.x] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm install | ||
| - run: npm test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,18 +4,18 @@ const splitInteger = require('./splitInteger'); | |
|
|
||
| test(`should split a number into equal parts | ||
| if a value is divisible by a numberOfParts`, () => { | ||
|
|
||
| expect(splitInteger(6, 2)).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 asserting exact equality for splitInteger(6, 2) is fine for the example. In addition, add a property-based test (for divisible case) that checks: - the returned array has length |
||
| }); | ||
|
|
||
| test(`should return a part equals to a value | ||
| when splitting into 1 part`, () => { | ||
|
|
||
| expect(splitInteger(8, 1)).toEqual([8]); | ||
|
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: this test covers the |
||
| }); | ||
|
|
||
| test('should sort parts ascending if they are not equal', () => { | ||
|
|
||
| expect(splitInteger(32, 6)).toEqual([5, 5, 5, 5, 6, 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. This example-based test for splitInteger(32, 6) is fine, but the task checklist requires a test for the example |
||
| }); | ||
|
|
||
| test('should add zeros if value < numberOfParts', () => { | ||
|
|
||
| expect(splitInteger(4, 6)).toEqual([0, 0, 1, 1, 1, 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. This test covers the |
||
| }); | ||
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 configuration disables the
no-protorule using a numeric severity (0). Consider one of the following for clarity:"no-proto": "off"so it's immediately clear to readers, or__proto__).Either approach improves maintainability but is not required for functionality.