Skip to content

Conversation

@sv4888
Copy link

@sv4888 sv4888 commented Jul 21, 2024

No description provided.

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.

Change your code and tests
when the mocks will be good, I'll get more deeply into the tests

getPointOnYAsis: Line.prototype.getPointOnYAsis,
getPointByX: Line.prototype.getPointByX,
getPointByY: Line.prototype.getPointByY
};
Copy link
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??? you don't export each prototype of a class

constructor({ x = 0, y = 0 } = {}) {

if (typeof (x) !== 'number' && typeof (y) !== 'number')
throw new Error('x and y is not number')
Copy link
Owner

Choose a reason for hiding this comment

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

x and y are not numbers

}

module.exports = Point No newline at end of file
module.exports = { Point, moveHorizontal: Point.prototype.moveHorizontal, moveVertical: Point.prototype.moveVertical };
Copy link
Owner

Choose a reason for hiding this comment

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

What is this exports?



const line2 = new Line({ point2: new Point({ x: 2, y: 5 }) });
expect(line2.point1).toStrictEqual(new Point());
Copy link
Owner

Choose a reason for hiding this comment

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

and what are the values of x and y?

describe('CONSTRUCTOR', () => {

it('should initialize x and y to default values when no parameters are provided', () => {

Copy link
Owner

Choose a reason for hiding this comment

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

don't write all test cases in one block, split them according to their test case
and write a good sentence that explains the test case



it('should initialize x and y to default values when no parameters are provided', () => {
point = new Point();
Copy link
Owner

Choose a reason for hiding this comment

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

split the test into different test cases

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 mocking is not correct...
try a different approach

"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.

Where is jest now?

const Line = require('../modules/ecs6-class/line');
const Point = require('../modules/ecs6-class/point');
const mockConstructor = jest.fn(constructor);

Copy link
Owner

Choose a reason for hiding this comment

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

this all mock function your wrote is not a way to mock class

@sv4888
Copy link
Author

sv4888 commented Jul 23, 2024

I'm trying a different approach with mocking, at the same time I want to know what I need to fix in my task: "create the server".

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.

I got only one update from last time



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.

what happens if slope is undefined?

@sv4888
Copy link
Author

sv4888 commented Jul 23, 2024

I don't understand the teacher's answer, I didn't get a response, is my task: "create the server" correct or not, I would like to know what the problems are with my task?

@gemtechd
Copy link
Owner

this is tests issue
write in the create server issue

@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