Conversation
|
I was not able to cover all the lines even though I did tests that went over those lines. |
gemtechd
left a comment
There was a problem hiding this comment.
You have to change much more code in themodules
and use good mocks in the tests
modules/ecs6-class/line.js
Outdated
| class Line { | ||
| constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { | ||
| constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { | ||
| this.point1 = point1; |
There was a problem hiding this comment.
you have to add more checks in the function
what happens when point is an array, what happens when n is a string etc...
| "test:coverage":"npm run test -- --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "jest": "^29.7.0" |
There was a problem hiding this comment.
jest cannot be in the dependency section
There was a problem hiding this comment.
why didn't you change the code?
| describe('CALCULATE_N_OF_LINE_FUNCTION',() => { | ||
| it('should return the correct answer',() => { | ||
| const line = new Line({point1:new Point({x:6,y:4}),point2:new Point({x:2,y:2})}) | ||
| line.calculateSlope() |
There was a problem hiding this comment.
here you don't call this function, you test a different function
There was a problem hiding this comment.
missing the errors
and the coverage for this module is under 70
There was a problem hiding this comment.
Don't call functions inside the tests beside the function that you test
You have to see that other functions will be getting called inside the tested function
use mocks for a function that is being called inside an other one
|
I want to move on to the next task. |
modules/ecs6-class/line.js
Outdated
| this.point1 = point1; | ||
| this.point2 = point2; | ||
| this.slope = slope; | ||
| this.n = n; |
There was a problem hiding this comment.
if n is not undefined but is also not a number
if slope is not undefined but also not a number???
modules/geometry-calculation.js
Outdated
| throw new Error('the type of point is not Point') | ||
| const proxyLine = new Line({ point1: line.point1, point2: point }) | ||
| proxyLine.calculateSlope() | ||
| if (line.slope === proxyLine.slope) { |
There was a problem hiding this comment.
Who said that the line's slope is already calculated?
| "test:coverage":"npm run test -- --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "jest": "^29.7.0" |
There was a problem hiding this comment.
why didn't you change the code?
|
|
||
| "license": "ISC", | ||
| "devDependencies": { | ||
| "nyc": "^17.0.0" |
There was a problem hiding this comment.
I installed it when I didn't manage with the tests, but in the end I managed.
|
Did you change code? |
gemtechd
left a comment
There was a problem hiding this comment.
Continue working on this task
| else{ | ||
| throw new Error('the type of point2 is not Point')} | ||
| else | ||
| throw new Error('the type of point2 is not Point') |
There was a problem hiding this comment.
Throw directly an error, like this, you don't mix up checks and codes
| // }) | ||
|
|
||
| // mockCalculatSlope.mockImplementation() | ||
|
|
There was a problem hiding this comment.
remove the remarks and console before pushing the commit
| it('An error should be thrown when line1 is not of type Line', () =>{ | ||
| const line2 = new Line({point1:new Point({x:8,y:3}),point2:new Point({x:6,y:1}),slope:1}) | ||
| line2.calculateNOfLineFunction() | ||
| line2.calculateNOfLineFunction() |
There was a problem hiding this comment.
don't execute a different function in a unittest
| it('should return true when the point on this line',() => { | ||
| const line = new Line({point1:new Point({x:8,y:4}),point2:new Point({x:2,y:1}),slope:0.5}) | ||
| line.calculateNOfLineFunction() | ||
| line.calculateNOfLineFunction() |
There was a problem hiding this comment.
Where are the mocks in the tests?
No description provided.