Conversation
gemtechd
left a comment
There was a problem hiding this comment.
Change your code and tests
when the mocks will be good, I'll get more deeply into the tests
modules/ecs6-class/line.js
Outdated
| getPointOnYAsis: Line.prototype.getPointOnYAsis, | ||
| getPointByX: Line.prototype.getPointByX, | ||
| getPointByY: Line.prototype.getPointByY | ||
| }; |
There was a problem hiding this comment.
What is this export??? you don't export each prototype of a class
modules/ecs6-class/point.js
Outdated
| constructor({ x = 0, y = 0 } = {}) { | ||
|
|
||
| if (typeof (x) !== 'number' && typeof (y) !== 'number') | ||
| throw new Error('x and y is not number') |
modules/ecs6-class/point.js
Outdated
| } | ||
|
|
||
| module.exports = Point No newline at end of file | ||
| module.exports = { Point, moveHorizontal: Point.prototype.moveHorizontal, moveVertical: Point.prototype.moveVertical }; |
|
|
||
|
|
||
| const line2 = new Line({ point2: new Point({ x: 2, y: 5 }) }); | ||
| expect(line2.point1).toStrictEqual(new Point()); |
There was a problem hiding this comment.
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', () => { | ||
|
|
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
split the test into different test cases
gemtechd
left a comment
There was a problem hiding this comment.
The way of mocking is not correct...
try a different approach
| "dependencies": { | ||
| "jest": "^29.7.0" | ||
| }, | ||
|
|
| const Line = require('../modules/ecs6-class/line'); | ||
| const Point = require('../modules/ecs6-class/point'); | ||
| const mockConstructor = jest.fn(constructor); | ||
|
|
There was a problem hiding this comment.
this all mock function your wrote is not a way to mock class
|
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". |
gemtechd
left a comment
There was a problem hiding this comment.
I got only one update from last time
|
|
||
|
|
||
| calculateNOfLineFunction = () => { | ||
| this.n = this.point1.y - this.slope * this.point1.x |
There was a problem hiding this comment.
what happens if slope is undefined?
|
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? |
|
this is tests issue |
No description provided.