Skip to content

Conversation

@M-Kroizer
Copy link

No description provided.

@M-Kroizer
Copy link
Author

I have tried a lot of ways to mock the class line while having the option to change the values of n and slope in the ctor.
i tried to make the mock class mockline at mock folder and to put there also furthermockline class but it didn't work well.
i have tried also to mock dynamically the line (deleting the mockline class from mock)
but now the mock doesn't work!!
I'm pushing now my not completed work
I would be happy to get some guidance on how to get on.

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.

Update your code
the tests weren't reviewed now

// })
// };
// });

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you push remarks?

constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) {
constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }={}) {
if(!(point1 instanceof Point) || !(point2 instanceof Point)){
throw new Error('points must be instances of point')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which point throws the error?


calculateSlope = () => {
calculateSlope () {
this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check that the x for both points are not identical? =>should divide by zero


calculateNOfLineFunction = () => {
calculateNOfLineFunction(){
this.n = this.point1.y - this.slope * this.point1.x
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 calculated??

getPointByX(x) {
getPointByX(x=0) {
if(typeof(x)!='number'){
throw new Error('value must be a number')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use always !== or ===

if(typeof(x)!='number'){
throw new Error('value must be a number')
}
let y = this.slope * x + this.n
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the n and slope calculated?

if(typeof(y)!='number'){
throw new Error('value must be a number')
}
let x = (y - this.n) / this.slope;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the n and the slope calculated?

throw new Error('must enter 2 lines')
if(!(line2 instanceof Line)||!(line1 instanceof Line))
throw new Error('lines must be instances of Line')
if (line1.slope === line2.slope) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the slopes calculated?

if(! (line instanceof Line))
throw new Error('line must be instance of Line')
const proxyLine = new Line({ point1: line.point1, point2: point })
proxyLine.calculateSlope()
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 calculated?

"coverage":"npm 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.

this is really not the good place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants