Skip to content

add mocks#15

Open
ws783 wants to merge 5 commits into
gemtechd:mainfrom
ws783:main
Open

add mocks#15
ws783 wants to merge 5 commits into
gemtechd:mainfrom
ws783:main

Conversation

@ws783

@ws783 ws783 commented Jul 21, 2024

Copy link
Copy Markdown

No description provided.

@gemtechd gemtechd left a comment

Copy link
Copy Markdown
Owner

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

Comment thread modules/ecs6-class/line.js Outdated
@@ -1,14 +1,29 @@
const Point = require("./point");
const { Point } = require("./point");

Copy link
Copy Markdown
Owner

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?

Comment thread 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')

Copy link
Copy Markdown
Owner

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

Comment thread 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')

Copy link
Copy Markdown
Owner

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

Comment thread modules/ecs6-class/line.js Outdated
}

module.exports = Line No newline at end of file
module.exports = {

Copy link
Copy Markdown
Owner

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

Comment thread modules/ecs6-class/point.js Outdated
Point:Point,
moveVertical: Point.prototype.moveVertical,
moveHorizontal: Point.prototype.moveHorizontal
}; No newline at end of file

Copy link
Copy Markdown
Owner

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");

Copy link
Copy Markdown
Owner

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");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

mock a ES6 class

Comment thread modules/geometry-calculation.js Outdated

const proxyLine = new Line({ point1: line.point1, point2: point });
proxyLine.calculateSlope();

Copy link
Copy Markdown
Owner

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?

@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