-
Notifications
You must be signed in to change notification settings - Fork 41
my tests #35
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?
my tests #35
Conversation
|
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. |
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.
Update your code
the tests weren't reviewed 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.
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') |
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.
Which point throws the error?
|
|
||
| calculateSlope = () => { | ||
| calculateSlope () { | ||
| this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) |
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.
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 |
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 calculated??
| getPointByX(x) { | ||
| getPointByX(x=0) { | ||
| if(typeof(x)!='number'){ | ||
| throw new Error('value must be a number') |
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.
use always !== or ===
| if(typeof(x)!='number'){ | ||
| throw new Error('value must be a number') | ||
| } | ||
| let y = this.slope * x + this.n |
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.
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; |
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.
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) { |
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.
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() |
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 calculated?
| "coverage":"npm 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.
this is really not the good place
No description provided.