-
Notifications
You must be signed in to change notification settings - Fork 41
add mocks #15
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?
add mocks #15
Conversation
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.
Change your code
I can't figure out your tests till it's going to be mocked the right way
modules/ecs6-class/line.js
Outdated
| @@ -1,14 +1,29 @@ | |||
| const Point = require("./point"); | |||
| const { Point } = require("./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.
Why did you change this line?
modules/ecs6-class/line.js
Outdated
|
|
||
| calculateSlope = () => { | ||
| if(this.point1.x === this.point2.x&&this.point1.y === this.point2.y){ | ||
| throw new Error('The point1 is equal to the point2 so it is not a line') |
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.
it's for sure on the same line, they are the same point
modules/ecs6-class/line.js
Outdated
| throw new Error('The point1 is equal to the point2 so it is not a line') | ||
| } | ||
| if(this.point1.x === this.point2.x){ | ||
| throw new Error('The x of point1 is equal to the x of point2 so it is not a line') |
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.
they are a line but the line is not a real function
modules/ecs6-class/line.js
Outdated
| } | ||
|
|
||
| module.exports = Line No newline at end of file | ||
| module.exports = { |
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.
export only the Line, all the rest are a part of the class
modules/ecs6-class/point.js
Outdated
| Point:Point, | ||
| moveVertical: Point.prototype.moveVertical, | ||
| moveHorizontal: Point.prototype.moveHorizontal | ||
| }; No newline at end of file |
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 is this export story???
for the mocks?
Did you search for how to mock a ES6 class
|
|
||
| const { Line } = require("./ecs6-class/line"); | ||
| const { Point } = require("./ecs6-class/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.
Get back to the previous import state
| @@ -0,0 +1,104 @@ | |||
|
|
|||
|
|
|||
| const { Line, getPointByX, getPointByY, } = require("../../modules/ecs6-class/line"); | |||
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.
mock a ES6 class
modules/geometry-calculation.js
Outdated
|
|
||
| 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.
What happens if the line doesn't have the slope or the n value?
No description provided.