Conversation
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') |
| 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.
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.
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.
Where are the good result for the line?
There was a problem hiding this comment.
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.
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.
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.
Where is the mocks for the line class?
There was a problem hiding this comment.
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.
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.
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.
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.
Where are the good tests for the constructor?
| LineInstance.getPointByX = mockGetPointByX; | ||
| const result = LineInstance.getPointOnYAsis(); | ||
| LineInstance.getPointOnYAsis(); | ||
| expect(mockGetPointByX).toHaveBeenCalledWith(0); |
| 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.
don't create instances of objects in the head of the module, each test gets its own objects to test
No description provided.