-
Notifications
You must be signed in to change notification settings - Fork 41
full coverage for the geometry-calculation project #11
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?
Conversation
|
Why is it closed? |
gemtechd
left a comment
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 way of the mockConstructor is total wrong
write the tests the correct way
| class Point { | ||
| constructor({x=0, y=0}={}) { | ||
| if (!(typeof (x) === "number") || !(typeof (y) === "number")) | ||
| throw new Error('x and y must be of the number type') |
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.
what happens if one is not a number?
I expect to get => if x is not a number : new Error(the parameter x must be a number) and if y is not a number: new Error(parameter y is not a number) if both are not numbers: new Error(both parameter must be type of number)
| } | ||
| const proxyLine = new Line({ point1: line.point1, point2: point }) | ||
| proxyLine.calculateSlope() | ||
| if (line.slope === proxyLine.slope) { |
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.
is the slope of line calculated?
is the n of line calculated?
| "test:coverage":"npm run test -- --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "jest": "^29.7.0" |
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.
jest is not in the dependecy section
|
|
||
| const mockConstructor1=jest.fn(constructor) | ||
| const mockConstructor=jest.fn(constructor) | ||
| const mockCalculateSlope=jest.fn(calculateSlope) |
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 way of mocks is total wrong
mock classes the right way and restore the mocks at the end of the tests
No description provided.