diff --git a/modules/ecs6-class/line.js b/modules/ecs6-class/line.js index b3bf0f7..b14da39 100644 --- a/modules/ecs6-class/line.js +++ b/modules/ecs6-class/line.js @@ -2,13 +2,29 @@ const Point = require("./point"); class Line { constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { + if (!(point1 instanceof Point)) + throw new Error('point1 is not point') this.point1 = point1; + if (!(point2 instanceof Point)) + throw new Error('point2 is not point') this.point2 = point2; + if (slope !== undefined && typeof slope !== 'number') + throw new Error('slope is not number') this.slope = slope; + if (n !== undefined && typeof (n) !== 'number') + throw new Error('n is not number') this.n = n; } calculateSlope = () => { + if(this.point1.x === this.point2.x&&this.point1.y === this.point2.y){ + throw new Error('Both points have the same values so it is not a line' + ) + } + if(this.point1.x === this.point2.x){ + throw new Error('The x of point1 is equal to the x of point2 so this line is not function') + } + this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) } @@ -26,14 +42,31 @@ class Line { getPointByX(x) { + if(x===undefined){ + throw Error('x is not a defined') + } + if(typeof(x)!=="number"){ + + throw Error('x is not a number') + } let y = this.slope * x + this.n return new Point({ x, y }) } getPointByY(y) { - let x = (y - this.slope) / this.n; + if(y===undefined){ + throw Error('y is not defined') + } + if(typeof(y)!=="number"){ + + throw Error('y is not number') + } + + let x = (y - this.n) / this.slope; return new Point({ x, y }) } } -module.exports = Line \ No newline at end of file +module.exports = Line + + diff --git a/modules/ecs6-class/point.js b/modules/ecs6-class/point.js index e81b4a4..b175ea6 100644 --- a/modules/ecs6-class/point.js +++ b/modules/ecs6-class/point.js @@ -1,14 +1,39 @@ class Point { - constructor({x=0, y=0}={}) { + + constructor({ x = 0, y = 0 } = {}) { + + if (typeof (x) !== "number" && typeof (y) != "number") { + throw Error('x and y are not number') + } + if (typeof (x) != "number") { + throw Error('x is not number') + } + if (typeof (y) != "number") { + throw Error('y is not number') + } this.x = x; this.y = y; } + moveVertical(value) { + if (!value) + throw Error("value is not define") + if(typeof(value)!=="number") + throw Error("value is not a number") this.y += value; } moveHorizontal(value) { + if (!value) + throw Error("value is not define") + if(typeof(value)!=="number") + throw Error("value is not a number") this.x += value; } } -module.exports = Point \ No newline at end of file + + +module.exports = Point + + + \ No newline at end of file diff --git a/modules/geometry-calculation.js b/modules/geometry-calculation.js index 66856dc..c35e51a 100644 --- a/modules/geometry-calculation.js +++ b/modules/geometry-calculation.js @@ -1,14 +1,42 @@ -const Line = require('./ecs6-class/line') + +const Line = require("./ecs6-class/line"); +const Point = require("./ecs6-class/point"); const calculateDistance = (point1, point2) => { + if (!(point1 instanceof Point) || !(point2 instanceof Point)) { + throw Error('point1 or point2 is not point'); + } let distanceX = (point2.x - point1.x) ** 2; - let distanceY = (point2.y - point2.y) ** 2; + let distanceY = (point2.y - point1.y) ** 2; const distance = Math.sqrt(distanceX + distanceY); return distance; } - const calculateJunctionPoint = (line1, line2) => { + if (!(line1 instanceof Line) && !(line2 instanceof Line)) { + throw Error('line1 and line2 is not a line'); + } + + if (!(line1 instanceof Line)) { + throw Error('line1 is not a line'); + } + + if (!(line2 instanceof Line)) { + throw Error('line2 is not a line'); + } + if (!line1.slope) { + line1.calculateSlope() + } + if (!line2.slope) { + line2.calculateSlope() + } + if (!line1.n) { + line1.calculateNOfLineFunction() + } + if (!line2.n) { + line2.calculateNOfLineFunction() + } if (line1.slope === line2.slope) { + if (line1.n === line2.n) { return true } @@ -23,18 +51,33 @@ const calculateJunctionPoint = (line1, line2) => { } } + const isPointOnLine = (line, point) => { - const proxyLine = new Line(line.point1, point) - proxyLine.calculateSlope() + if (!(line instanceof Line) || !(point instanceof Point)) { + throw new Error('line is not point or point is not a line'); + } + + const proxyLine = new Line({ point1: line.point1, point2: point }); + proxyLine.calculateSlope(); + if (!line.slope) { + line.calculateSlope() + } + if(!line.n){ + line.calculateNOfLineFunction() + } if (line.slope === proxyLine.slope) { - proxyLine.calculateNOfLineFunction() - if (line.n === proxyLine.n2) { - return true + proxyLine.calculateNOfLineFunction(); + + if (line.n === proxyLine.n) { + return true; + } + else { + return false } } - return false -} + return false; +}; module.exports = { calculateDistance, calculateJunctionPoint, diff --git a/package.json b/package.json index 56bf17b..6935a4b 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,8 @@ "description": "practice unit tests in javascript", "main": "index.js", "scripts": { - "test": "jest" - }, - "dependencies": { - "jest": "^29.7.0" + "test": "jest", + "test:coverage": "npm run test -- --coverage" }, "repository": { "type": "git", diff --git a/tests/modules/ecs6-class/line.test.js b/tests/modules/ecs6-class/line.test.js new file mode 100644 index 0000000..f3e0b2b --- /dev/null +++ b/tests/modules/ecs6-class/line.test.js @@ -0,0 +1,173 @@ + +const Line = require('../../../modules/ecs6-class/line'); +const Point = require('../../../modules/ecs6-class/point') +const mockConstructor = jest.fn(constructor); +let line +describe('CONSTRUCTORE', () => { }) + + +it('should initialize point2, n and slope to default values when no parameters are provided', () => { + line = new Line({ point1: mockConstructor(new Point({ x: 1, y: 5 })) }); + expect(line.point1).toStrictEqual(mockConstructor(new Point({ x: 1, y: 5 }))) + expect(line.point2).toStrictEqual(mockConstructor(new Point())) + expect(line.n).toBe(undefined) + expect(line.slope).toBe(undefined) +}) +it('should initialize point1, n and value to default values when no parameters are provided', () => { + line = new Line({ point2: mockConstructor(new Point({ x: 1, y: 5 })) }); + expect(line.point1).toStrictEqual(mockConstructor(new Point())) + expect(line.point2).toStrictEqual(mockConstructor(new Point({ x: 1, y: 5 }))) + expect(line.n).toBe(undefined) + expect(line.slope).toBe(undefined) +}) +it('should initialize point1, point2 and slope to default values when no parameters are provided', () => { + line = new Line({ n: 5 }); + expect(line.point1).toStrictEqual(mockConstructor(new Point())) + expect(line.point2).toStrictEqual(mockConstructor(new Point())) + expect(line.n).toBe(5) + expect(line.slope).toBe(undefined) +}) +it('should initialize point1, point2 and n to default values when no parameters are provided', () => { + line = new Line({ slope: 5 }); + expect(line.point1).toStrictEqual(mockConstructor(new Point())) + expect(line.point2).toStrictEqual(mockConstructor(new Point())) + expect(line.n).toBe(undefined) + expect(line.slope).toBe(5) +}) +it('should initialize to default values when no parameters are provided', () => { + line = new Line({}) + expect(line.point1).toStrictEqual(mockConstructor(new Point())) + expect(line.point2).toStrictEqual(mockConstructor(new Point())) + expect(line.n).toBe(undefined) + expect(line.slope).toBe(undefined) + +}) +it('Checks if the parameters are of the correct type', () => { + + expect(() => new Line({ point1: "ab", point2: new Point({ x: 5, y: 5 }), slope: 1, n: 5 })).toThrow('point1 is not point'); + expect(() => new Line({ point1: mockConstructor(new Point({ x: 5, y: 5 })), point2: "ab", slope: 1, n: 5 })).toThrow('point2 is not point'); + expect(() => new Line({ point1: new Point({ x: 5, y: 5 }), point2: mockConstructor(new Point({ x: 5, y: 5 })), slope: "d", n: 5 })).toThrow('slope is not number'); + expect(() => new Line({ point1: new Point({ x: 5, y: 5 }), point2: mockConstructor(new Point({ x: 5, y: 5 })), slope: 1, n: "d" })).toThrow('n is not number'); +}) +it('Point constructor initializes point1 and point2 and slope and n correctly', () => { + line = new Line({ point1: mockConstructor(new Point({ x: 5, y: 8 })), point2: mockConstructor(new Point({ x: 5, y: 8 })), slope: 5, n: 8 }); + expect(line.point1).toEqual(mockConstructor(new Point({ x: 5, y: 8 }))); + expect(line.point2).toEqual(mockConstructor(new Point({ x: 5, y: 8 }))); + expect(line.slope).toBe(5); + expect(line.n).toBe(8); + +}); +describe('CALCULATE_SLOPE', () => { + + it('should The slope is 0 as the line is vertical (point1= point2) ', () => { + line = mockConstructor(new Line(({ point1: mockConstructor(new Point({ x: 5, y: 8 })), point2: mockConstructor(new Point({ x: 5, y: 8 })), n: 8 }))) + expect(() => line.calculateSlope()).toThrow('Both points have the same values so it is not a line'); + + }) + + it('should The slope is undefined as the line is vertical (y1 = y2) ', () => { + line = mockConstructor(new Line(({ point1: mockConstructor(new Point({ x: 5, y: 8 })), point2: mockConstructor(new Point({ x: 3, y: 8 })), slope: 5, n: 8 }))) + line.calculateSlope() + expect(line.slope).toBeCloseTo(0); + + }) + it('should The slope is undefined as the line is vertical (x1=x2)', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 5, y: 9 })), point2: mockConstructor(new Point({ x: 5, y: 8 })), n: 8 })); + expect(() => line.calculateSlope()).toThrow('The x of point1 is equal to the x of point2 so this line is not function'); + }); + + it('should move vertically correctly', () => { + line = mockConstructor(new Line(({ point1: mockConstructor(new Point({ x: -1, y: 8 })), point2: mockConstructor(new Point({ x: 2, y: 5 })), slope: 5, n: 8 }))); + line.calculateSlope() + expect(line.slope).toBe(-1); + + }) + +}) +describe('CALCULATE_N_OF_LINE_FUNCTION', () => { + it(' should move vertically correctly', () => { + line = mockConstructor(new Line(({ point1: mockConstructor(new Point({ x: 5, y: 8 })), point2: mockConstructor(new Point({ x: 5, y: 5 })), slope: 1, n: 8 }))); + line.calculateNOfLineFunction() + expect(line.n).toBe(3); + + }) + +}) + +describe('GET_POINT_BY_X', () => { + it('should x is not define ', () => { + const line = mockConstructor(new Line({})) + expect(() => line.getPointByX()).toThrow('x is not a defined'); + }) + + it('should x is not number ', () => { + const line = mockConstructor(new Line({})) + expect(() => line.getPointByX("abc")).toThrow('x is not a number'); + }) + + it(' should check that the returned value is of type point', () => { + const line = mockConstructor(new Line({})) + const point = line.getPointByX(5) + expect(point).toBeInstanceOf(Point) + + }) + it('should checks that point is returned with correct values', () => { + const line = mockConstructor(new Line(({ point1: new Point({ x: 5, y: 8 }), point2: new Point({ x: 5, y: 5 }), slope: 1, n: 8 }))) + initialx = line.point1.x + const point = line.getPointByX(5) + expect(point.x).toBe(initialx) + expect(point.y).toBe(13) + }) +}) +describe('GET_POINT_B_Y', () => { + it('should y is not define ', () => { + const line = mockConstructor(new Line({})) + expect(() => line.getPointByY()).toThrow('y is not defined'); + }) +}) + +it('should y is not number ', () => { + const line = mockConstructor(new Line({})) + expect(() => line.getPointByY("abc")).toThrow('y is not number'); +}) + +it(' should check that the returned value is of type point', () => { + const line = mockConstructor(new Line({})) + const point = line.getPointByY(5) + expect(point).toBeInstanceOf(Point) + +}) +it('should checks that point is returned with correct values', () => { + const line = mockConstructor(new Line(({ point1: mockConstructor(new Point({ x: 8, y: 6 })), point2: mockConstructor(new Point({ x: 5, y: 5 })), slope: 1, n: 3 }))) + initialy = line.point1.y + const point = line.getPointByY(6) + expect(point.x).toBe(3) + expect(point.y).toBe(initialy) +}) + +describe('GET_POINT_ON_X_ASIS', () => { + + it('returns the correct point on the y-axis for the given slope and n value', () => { + + const line = mockConstructor(new Line(({ slope: 2, n: -6 }))) + const point = line.getPointOnXAsis() + expect(point.y).toBe(0) + expect(point.x).toBe(3) + + + + }) +}) +describe('GET_POINT_ON_Y_ASIS', () => { + it('returns the correct point on the y-axis for the given slope and n value', () => { + const line = mockConstructor(new Line({ slope: 5, n: 5 })) + const point = line.getPointOnYAsis() + expect(point.y).toBe(5) + expect(point.x).toBe(0) + + + }) +}) + + + diff --git a/tests/modules/ecs6-class/point.test.js b/tests/modules/ecs6-class/point.test.js new file mode 100644 index 0000000..2f1ee9a --- /dev/null +++ b/tests/modules/ecs6-class/point.test.js @@ -0,0 +1,75 @@ +const Point = require('../../../modules/ecs6-class/point') +const mockConstructor = jest.fn(constructor); +let point +describe('CONSTRUCTORE', () => { + + it('should throw error when x or y is not a number', () => { + const x = "abc"; + const y = "s"; + expect(() => new Point({ x: x, y: 5 })).toThrow('x is not number'); + expect(() => new Point({ x: 5, y: y })).toThrow('y is not number'); + expect(() => new Point({ x: x, y: y })).toThrow('x and y are not number'); + }); + it('should initialize x and y to default values when no parameters are provided', () => { + point = new Point({ x: 0, y: 0 }); + expect(point.x).toBe(0) + expect(point.y).toBe(0)}) + it('should initialize y to default value when no parameters are provided', () => { + point = new Point({ x: 5 }); + expect(point.x).toBe(5) + expect(point.y).toBe(0)}) + it('should initialize x to default value when no parameters are provided', () => { + point = new Point({ y: 5 }); + expect(point.x).toBe(0) + expect(point.y).toBe(5) + + }); + + it('Point constructor initializes x and y correctly', () => { + point = new Point({ x: 3, y: 4 }); + expect(point.x).toBe(3); + expect(point.y).toBe(4); + }); + +}) + + +describe('MOVE_VERTICAL', () => { + + it('should value is not define ', () => { + point = mockConstructor(new Point()) + expect(() => point.moveVertical()).toThrow('value is not define'); + }) + it("should value is not a number", () => { + + expect(() => point.moveVertical("abc")).toThrow('value is not a number'); + }) + it('should update y correctly when moved vertically', () => { + point = mockConstructor(new Point({ x: 5, y: 2 })) + point.moveVertical(5) + expect(point.y).toBe(7) + }) + +}) +describe('MOVE_HORIZONAL', () => { + + + it('should value is not define ', () => { + point = mockConstructor(new Point()) + expect(() => point.moveHorizontal()).toThrow('value is not define'); + }) + + it("should value is not a number", () => { + + expect(() => point.moveHorizontal("abc")).toThrow('value is not a number'); + }) + + it('should move vertically correctly', () => { + point = mockConstructor(new Point({ x: 5, y: 2 })) + point.moveHorizontal(5) + expect(point.x).toBe(5 + 5) + + }) +}) + + diff --git a/tests/modules/geometry-calculation.test.js b/tests/modules/geometry-calculation.test.js new file mode 100644 index 0000000..f93c52f --- /dev/null +++ b/tests/modules/geometry-calculation.test.js @@ -0,0 +1,165 @@ + + +const Line = require("../../modules/ecs6-class/line"); +const Point = require("../../modules/ecs6-class/point"); +const { isPointOnLine, calculateDistance, calculateJunctionPoint } = require('../../modules/geometry-calculation') +const mockConstructor = jest.fn(constructor); +Line.prototype.getPointByX = jest.fn().mockImplementation((x) => { + return new Point({ x: 2, y: 12 }); +}); +Line.prototype.calculateSlope = jest.fn().mockImplementation(() => { + line.slope = 1; +}); + +Line.prototype.calculateNOfLineFunction = jest.fn().mockImplementation(() => { + line.n = 5; +}); + + +let line +describe('CALCULATE_DISTANCE', () => { + it(' should checks if the parameters are of the correct type', () => { + expect(() => calculateDistance('ab', 'df')).toThrow('point1 or point2 is not point'); + expect(() => calculateDistance('ab', mockConstructor(new Point()))).toThrow('point1 or point2 is not point'); + expect(() => calculateDistance(mockConstructor(new Point(), 'av'))).toThrow('point1 or point2 is not point'); + }) + it(' should checks the distance between two lines if it correct', () => { + + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 1, n: 5 })) + const distance = calculateDistance(line.point1, line.point2) + expect(distance).toBe(5) + }) +}) +describe('CALCULATE_JUNCTION_POINT', () => { + + + it(' should checks if the line1 and line2 are of the correct type', () => { + expect(() => calculateJunctionPoint('ab', 'df')).toThrow('line1 and line2 is not a line'); + }) + + it(' should checks if the line1 is of the correct type', () => { + expect(() => calculateJunctionPoint('ab', mockConstructor(new Line({})))).toThrow('line1 is not a line'); + }) + + it(' should checks if the line2 is of the correct type', () => { + expect(() => calculateJunctionPoint(mockConstructor(new Line({})), 'av')).toThrow('line2 is not a line'); + }) + it('should calculate the slope value for line1 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), n: 5 })) + const line1 = mockConstructor(new Line({ slope: 1, n: 4 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + it('should calculate the slope value for line2 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ slope: 1, n: 4 })) + const line1 = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), n: 5 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + it('should calculate the slope value for line and line2 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), n: 5 })) + const line1 = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), n: 4 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + it('should calculate the n value for line1 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), slope: 1 })) + const line1 = mockConstructor(new Line({ slope: 1, n: 4 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + it('should calculate the n value for line2 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), slope: 1, n: 5 })) + const line1 = mockConstructor(new Line({ slope: 1 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + it('should calculate the n value for line1 and line2 and then proceed with the calculation', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 7, y: 9 }), slope: 1 })) + const line1 = mockConstructor(new Line({ slope: 1 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + + it('should return true for specific input', () => { + + line = mockConstructor(new Line({ slope: 1, n: 5 })) + const line1 = mockConstructor(new Line({ slope: 1, n: 5 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(true); + }); + + it('should return false for specific input', () => { + + line = mockConstructor(new Line({ point1: new Point({ x: 4, y: 6 }), point2: new Point({ x: 8, y: 9 }), slope: 1, n: 5 })) + const line1 = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 5 })), slope: 1, n: 6 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toBe(false); + }); + + it(' should calculateJunctionPoint return the correct junction point for the given lines', () => { + + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 1, n: 10 })) + const line1 = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 5 })), slope: 5, n: 2 })) + const result = calculateJunctionPoint(line, line1) + expect(result).toEqual(mockConstructor(new Point({ x: 2, y: 12 }))); + + }); + + +}) +describe('IS_POINT_ON_LINE', () => { + let point + it(' should checks if the parameters are of the correct type', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 1, n: 10 })) + point = mockConstructor(new Point({ x: 4, y: 6 })) + expect(() => isPointOnLine("k", "j")).toThrow('line is not point or point is not a line'); + expect(() => isPointOnLine(line, "abc")).toThrow('line is not point or point is not a line'); + expect(() => isPointOnLine("c", point)).toThrow('line is not point or point is not a line'); + }) + it('should calculate the slope of the line when it is missing and then proceed to check if the point lies on the line', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), n: -6 })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(false); + }) + it('should calculate the n of the line when it is missing and then proceed to check if the point lies on the line', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 1 })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(false); + }) + + it('should Point lies isnt on a line with slope and n values', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 2, })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(false); + }) + it('should Point lies isnt on a line with slope and n values', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: 2, n: -6 })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(false); + }) + it('should Point lies isnt on a line with slope and n values', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: -2, n: -6 })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(false); + }) + it('should Point lies on a line with slope and n values', () => { + line = mockConstructor(new Line({ point1: mockConstructor(new Point({ x: 4, y: 6 })), point2: mockConstructor(new Point({ x: 8, y: 9 })), slope: -2, n: 14 })) + point = mockConstructor(new Point({ x: 5, y: 4 })) + const result = isPointOnLine(line, point) + expect(result).toBe(true); + }) +}) + +