-
Notifications
You must be signed in to change notification settings - Fork 41
add tests #24
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 #24
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.
See the comments
modules/ecs6-class/line.js
Outdated
| class Line { | ||
| constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { | ||
| if(!(point1 instanceof(Point)) || !(point2 instanceof(Point))) | ||
| throw new Error('argument should be a 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.
Which argument?
| if(!(line1 instanceof(Line)) || !(line2 instanceof(Line))) | ||
| throw new Error('the argument should be line') | ||
| if (line1.slope === line2.slope) { | ||
| if (line1.n === line2.n) { |
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 slope was not calculated or n was not calculated?
| "coverage": "npm run test -- --coverage" | ||
| }, | ||
| "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.
this is not the right place for the jest module
tests/ecs6-class/line.test.js
Outdated
| const line1 = new Line({}); | ||
|
|
||
| describe('ERRORS', () => { | ||
| test('should throw string error when argument are no 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.
Where are the good result for the 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.
Where are the good tests for the constructor?
tests/ecs6-class/line.test.js
Outdated
| }) | ||
|
|
||
| describe('CALCULATE_SLOPE', () => { | ||
| test('should calculate the slope', () => { |
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 are the excpetions of the function?
| const LineInstance = new Line({}); | ||
| LineInstance.getPointByY = mockGetPointByY; | ||
| const result = LineInstance.getPointOnXAsis(); | ||
| expect(mockGetPointByY).toHaveBeenCalledWith(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.
this expect line is unnecessary
| const point6 = new Point({ x: 1, y: 1 }); | ||
| const line4 = new Line({ point1: point5, point2: point6, slope: 1, n: 0 }); | ||
| const line5 = new Line({ point1: point5, point2: point4, slope: 1, n: 3 }); | ||
|
|
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 the mocks for the line class?
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 create instances of objects in the head of the module, each test gets its own objects to test
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.
You have to build your tests structure again.
use the it test function instead of test
package.json
Outdated
| "dependencies": { | ||
| "jest": "^29.7.0" | ||
| "jest": "^29.7.0", | ||
| "coverage": "npm run test -- --coverage" |
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.
is coverage a dependency?
does jest belong to the dependencies?
tests/ecs6-class/line.test.js
Outdated
| const line3 = new Line({}); | ||
| line3.slope = 2; | ||
| const line4 = new Line({ point1, point2 }); | ||
| line4.n = 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.
Don't define some objects in the begin of the module, each test should get its own objects,
tests/ecs6-class/line.test.js
Outdated
| const line1 = new Line({}); | ||
|
|
||
| describe('ERRORS', () => { | ||
| test('should throw string error when argument are no 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.
Where are the good tests for the constructor?
| LineInstance.getPointByX = mockGetPointByX; | ||
| const result = LineInstance.getPointOnYAsis(); | ||
| LineInstance.getPointOnYAsis(); | ||
| expect(mockGetPointByX).toHaveBeenCalledWith(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.
What is this test?
| const point6 = new Point({ x: 1, y: 1 }); | ||
| const line4 = new Line({ point1: point5, point2: point6, slope: 1, n: 0 }); | ||
| const line5 = new Line({ point1: point5, point2: point4, slope: 1, n: 3 }); | ||
|
|
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 create instances of objects in the head of the module, each test gets its own objects to test
No description provided.