-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Implement check #2243
base: Searchingdays
Are you sure you want to change the base?
Implement check #2243
Conversation
Thank you for the submission, @Searchingdays! I'll review your code shortly, hang tight. |
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.
This is a great attempt, @Searchingdays!
I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.
After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.
When you push your changes to your fork, I'll come back for another review.
There are 6 style guide violations in your contribution. I've marked them with inline comments for your convenience.
Please revisit your code and follow the style guide best practices.
Hint: You might be able to fix some issues automatically by running npm run lint -- --fix
There was an error when running npm test
. Please revisit your code and fix this error.
/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.js:15
it('should throw a TypeError if arguments are not numbers', (exports._check) => {
^^^^^^^^^^^^^^
SyntaxError: Invalid destructuring assignment target
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.test.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at /var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
src/calculator.js
Outdated
calculator._check.restore(); | ||
}); | ||
|
||
it('should throw a TypeError if arguments are not numbers', (exports._check) => { |
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.
Parsing error: Assigning to rvalue
src/calculator.test.js
Outdated
@@ -10,7 +10,7 @@ describe.skip('_check', () => { | |||
calculator._check.restore(); | |||
}); | |||
|
|||
it('should throw a TypeError if arguments are not numbers', () => { | |||
it('should throw a TypeError if arguments are not numbers', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
@@ -19,25 +19,25 @@ describe.skip('_check', () => { | |||
expect(() => calculator._check({}, 2)).to.throw(TypeError); | |||
}); | |||
|
|||
it('should be called once in "add"', () => { | |||
it('should be called once in "add"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.add(40, 2); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(40, 2); | ||
}); | ||
|
||
it('should be called once in "subtract"', () => { | ||
it('should be called once in "subtract"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.subtract(44, 2); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(44, 2); | ||
}); | ||
|
||
it('should be called once in "multiply"', () => { | ||
it('should be called once in "multiply"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.multiply(6, 7); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(6, 7); | ||
}); | ||
|
||
it('should be called once in "divide"', () => { | ||
it('should be called once in "divide"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
Thanks for the changes, @Searchingdays. I'm reviewing them now. |
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.
This is a great attempt, @Searchingdays!
I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.
After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.
When you push your changes to your fork, I'll come back for another review.
There are 6 style guide violations in your contribution. I've marked them with inline comments for your convenience.
Please revisit your code and follow the style guide best practices.
Hint: You might be able to fix some issues automatically by running npm run lint -- --fix
There was an error when running npm test
. Please revisit your code and fix this error.
/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.js:15
it('should throw a TypeError if arguments are not numbers', (exports._check) => {
^^^^^^^^^^^^^^
SyntaxError: Invalid destructuring assignment target
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.test.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at /var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
src/calculator.js
Outdated
calculator._check.restore(); | ||
}); | ||
|
||
it('should throw a TypeError if arguments are not numbers', (exports._check) => { |
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.
Parsing error: Assigning to rvalue
src/calculator.test.js
Outdated
@@ -10,7 +10,7 @@ describe.skip('_check', () => { | |||
calculator._check.restore(); | |||
}); | |||
|
|||
it('should throw a TypeError if arguments are not numbers', () => { | |||
it('should throw a TypeError if arguments are not numbers', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
@@ -19,25 +19,25 @@ describe.skip('_check', () => { | |||
expect(() => calculator._check({}, 2)).to.throw(TypeError); | |||
}); | |||
|
|||
it('should be called once in "add"', () => { | |||
it('should be called once in "add"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.add(40, 2); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(40, 2); | ||
}); | ||
|
||
it('should be called once in "subtract"', () => { | ||
it('should be called once in "subtract"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.subtract(44, 2); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(44, 2); | ||
}); | ||
|
||
it('should be called once in "multiply"', () => { | ||
it('should be called once in "multiply"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
src/calculator.test.js
Outdated
calculator.multiply(6, 7); | ||
expect(calculator._check).to.have.been.calledOnce; | ||
expect(calculator._check).to.have.been.calledWith(6, 7); | ||
}); | ||
|
||
it('should be called once in "divide"', () => { | ||
it('should be called once in "divide"', (_check) => { |
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.
'_check' is defined but never used.
(learn more)
Thanks for the changes, @Searchingdays. I'm reviewing them now. |
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.
This is a great attempt, @Searchingdays!
I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.
After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.
When you push your changes to your fork, I'll come back for another review.
There are 1 style guide violations in your contribution. I've marked them with inline comments for your convenience.
Please revisit your code and follow the style guide best practices.
Hint: You might be able to fix some issues automatically by running npm run lint -- --fix
There was an error when running npm test
. Please revisit your code and fix this error.
/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.js:16
expect(() => calculator._check(40, '2')).to.throw(TypeError);
^
SyntaxError: Unexpected token '('
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/src/calculator.test.js:2:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at /var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/var/lib/buildkite-agent/builds/dispatchtrackimporter-1/contribute-to-open-source/contribute-to-open-source/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
src/calculator.js
Outdated
}); | ||
|
||
it('should throw a TypeError if arguments are not numbers', (exports._check) == { | ||
expect(() => calculator._check(40, '2')).to.throw(TypeError); |
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.
Parsing error: Unexpected token (
Thanks for the changes, @Searchingdays. I'm reviewing them now. |
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.
This is a great attempt, @Searchingdays!
I would like to request a few changes before merging your work. Please review my comments below and make the appropriate changes to your code.
After you update your code locally, follow the instructions to save your changes locally and push your changes to your fork.
When you push your changes to your fork, I'll come back for another review.
There are 20 style guide violations in your contribution. I've marked them with inline comments for your convenience.
Please revisit your code and follow the style guide best practices.
Hint: You might be able to fix some issues automatically by running npm run lint -- --fix
There are 1 tests failing. Please revisit your code and make the failing tests pass.
❌ _check should throw a TypeError if arguments are not numbers
-actual
+expected
-
+function TypeError() { [native code] }
AssertionError: expected [Function] to throw TypeError
at Context.<anonymous> (src/calculator.test.js:14:54)
at processImmediate (node:internal/timers:464:21)
@@ -1,14 +1,15 @@ | |||
exports._check = () => { | |||
exports._check = (x,y) => { |
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.
A space is required after ','.
(learn more)
@@ -1,14 +1,15 @@ | |||
exports._check = () => { | |||
exports._check = (x,y) => { |
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.
'y' is defined but never used.
(learn more)
// DRY up the codebase with this function | ||
// First, move the duplicate error checking code here | ||
// Then, invoke this function inside each of the others | ||
// HINT: you can invoke this function with exports._check() | ||
}; | ||
|
||
|
||
exports.add = (x, y) => { |
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.
Expected indentation of 2 spaces but found 0.
(learn more)
// DRY up the codebase with this function | ||
// First, move the duplicate error checking code here | ||
// Then, invoke this function inside each of the others | ||
// HINT: you can invoke this function with exports._check() | ||
}; | ||
|
||
|
||
exports.add = (x, y) => { |
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.
'x' is already declared in the upper scope.
(learn more)
// DRY up the codebase with this function | ||
// First, move the duplicate error checking code here | ||
// Then, invoke this function inside each of the others | ||
// HINT: you can invoke this function with exports._check() | ||
}; | ||
|
||
|
||
exports.add = (x, y) => { |
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.
'y' is already declared in the upper scope.
(learn more)
@@ -22,6 +23,7 @@ exports.subtract = (x, y) => { | |||
if (typeof y !== 'number') { | |||
throw new TypeError(`${y} is not a number`); | |||
} | |||
exports._check(x,y) |
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.
A space is required after ','.
(learn more)
@@ -22,6 +23,7 @@ exports.subtract = (x, y) => { | |||
if (typeof y !== 'number') { | |||
throw new TypeError(`${y} is not a number`); | |||
} | |||
exports._check(x,y) |
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.
Missing semicolon.
(learn more)
@@ -32,6 +34,7 @@ exports.multiply = (x, y) => { | |||
if (typeof y !== 'number') { | |||
throw new TypeError(`${y} is not a number`); | |||
} | |||
exports._check(x,y); |
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.
A space is required after ','.
(learn more)
@@ -42,7 +45,9 @@ exports.divide = (x, y) => { | |||
if (typeof y !== 'number') { | |||
throw new TypeError(`${y} is not a number`); | |||
} | |||
exports._check(x,y); |
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.
A space is required after ','.
(learn more)
return x / y; | ||
}; | ||
} |
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.
Missing semicolon.
(learn more)
No description provided.