Skip to content

Conversation

@Rudi-Np
Copy link

@Rudi-Np Rudi-Np commented Jul 18, 2024

No description provided.

@Rudi-Np Rudi-Np closed this Jul 18, 2024
@gemtechd
Copy link
Owner

Why is it closed?

@Rudi-Np Rudi-Np reopened this Jul 22, 2024
Copy link
Owner

@gemtechd gemtechd left a 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')
Copy link
Owner

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) {
Copy link
Owner

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"
Copy link
Owner

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)
Copy link
Owner

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

@gemtechd gemtechd added the bb label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants