-
Notifications
You must be signed in to change notification settings - Fork 41
add tests #14
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 tests #14
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 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.
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
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') |
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.
x and y are not numbers
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 }; |
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 exports?
|
|
||
|
|
||
| const line2 = new Line({ point2: new Point({ x: 2, y: 5 }) }); | ||
| expect(line2.point1).toStrictEqual(new 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.
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.
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(); |
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.
split the test into different test cases
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.
The way of mocking is not correct...
try a different approach
| "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.
Where is jest now?
| 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.
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
|
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.
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 |
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 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.