full coverage for the geometry-calculation project#11
full coverage for the geometry-calculation project#11Rudi-Np wants to merge 1 commit intogemtechd:mainfrom
Conversation
|
Why is it closed? |
gemtechd
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.