From 6591e058ef68c0f6c51b6ac21f9e6f1b8a0009da Mon Sep 17 00:00:00 2001 From: "m.Mendelsohn" Date: Mon, 22 Jul 2024 09:38:56 +0300 Subject: [PATCH 1/6] create tests --- modules/ecs6-class/line.js | 18 ++++++++++++++++++ modules/ecs6-class/point.js | 9 +++++++++ modules/geometry-calculation.js | 16 +++++++++++++++- package.json | 3 ++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/modules/ecs6-class/line.js b/modules/ecs6-class/line.js index 826c675..59579cb 100644 --- a/modules/ecs6-class/line.js +++ b/modules/ecs6-class/line.js @@ -2,6 +2,12 @@ const Point = require("./point"); class Line { constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { + if(typeof(point1)!="object" && point1 !=undefined || typeof(point2)!="object" && point2 !=undefined){ + throw new Error('argument must be type point') + } + if (typeof(n)!="number"&& n !=undefined|| typeof(slope)!="number" && slope !=undefined){ + throw new Error('argument must be type number') + } this.point1 = point1; this.point2 = point2; this.slope = slope; @@ -9,10 +15,16 @@ class Line { } calculateSlope = () => { + if( this.point1.x==this.point1.y && this.point1.y==0 || this.point2.x==this.point2.y && this.point2.y==0){ + throw new Error("missing data") + } this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) } calculateNOfLineFunction = () => { + if(this.slope==undefined || this.point1==undefined){ + throw new Error("missing data") + } this.n = this.point1.y - this.slope * this.point1.x } @@ -26,11 +38,17 @@ class Line { getPointByX(x) { + if(typeof(x)!="number"){ + throw new Error('argument must be type number') + } let y = this.slope * x + this.n return new Point({ x, y }) } getPointByY(y) { + if(typeof(y)!="number"){ + throw new Error('argument must be type number') + } let x = (y - this.n) / this.slope; return new Point({ x, y }) } diff --git a/modules/ecs6-class/point.js b/modules/ecs6-class/point.js index e81b4a4..b6c099d 100644 --- a/modules/ecs6-class/point.js +++ b/modules/ecs6-class/point.js @@ -1,12 +1,21 @@ class Point { constructor({x=0, y=0}={}) { + if(typeof(x)!="number" || typeof(y)!="number"){ + throw new Error('argument must be type number') + } this.x = x; this.y = y; } moveVertical(value) { + if(typeof(value)!="number"){ + throw new Error('argument must be type number') + } this.y += value; } moveHorizontal(value) { + if(typeof(value)!="number"){ + throw new Error('argument must be type number') + } this.x += value; } } diff --git a/modules/geometry-calculation.js b/modules/geometry-calculation.js index 6e11643..ed4c6b6 100644 --- a/modules/geometry-calculation.js +++ b/modules/geometry-calculation.js @@ -1,13 +1,24 @@ const Line = require('./ecs6-class/line') +const Point = require('./ecs6-class/point') const calculateDistance = (point1, point2) => { + if (!point1 || !point2) { + throw new Error('missing data') + } + if (typeof (point1) != 'object' | typeof (point2) != 'object') { + throw new Error('argument must by type 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 == undefined || line2 == undefined) { + throw new Error("missing data") + } if (line1.slope === line2.slope) { if (line1.n === line2.n) { return true @@ -24,6 +35,9 @@ const calculateJunctionPoint = (line1, line2) => { } const isPointOnLine = (line, point) => { + if (line == undefined || point == undefined) { + throw new Error("missing data") + } const proxyLine = new Line({ point1: line.point1, point2: point }) proxyLine.calculateSlope() if (line.slope === proxyLine.slope) { diff --git a/package.json b/package.json index 56bf17b..355814a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "practice unit tests in javascript", "main": "index.js", "scripts": { - "test": "jest" + "test": "jest", + "test:coverage":"jest --coverage" }, "dependencies": { "jest": "^29.7.0" From 3c70d332740da51d7a91da2f77f09ad8d3188dfe Mon Sep 17 00:00:00 2001 From: "m.mendelsohn" Date: Tue, 23 Jul 2024 16:04:58 +0300 Subject: [PATCH 2/6] create test --- modules/ecs6-class/line.js | 16 +- modules/ecs6-class/point.js | 6 +- modules/geometry-calculation.js | 3 +- package-lock.json | 439 +++++++++++++++++++++++++++++++- package.json | 5 + 5 files changed, 457 insertions(+), 12 deletions(-) diff --git a/modules/ecs6-class/line.js b/modules/ecs6-class/line.js index 59579cb..ad44480 100644 --- a/modules/ecs6-class/line.js +++ b/modules/ecs6-class/line.js @@ -2,10 +2,10 @@ const Point = require("./point"); class Line { constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { - if(typeof(point1)!="object" && point1 !=undefined || typeof(point2)!="object" && point2 !=undefined){ + if(!(point1 instanceof Point)|| !(point2 instanceof Point)){ throw new Error('argument must be type point') } - if (typeof(n)!="number"&& n !=undefined|| typeof(slope)!="number" && slope !=undefined){ + if (typeof(n)!="number"&& n !==undefined|| typeof(slope)!=="number" && slope !=undefined){ throw new Error('argument must be type number') } this.point1 = point1; @@ -16,14 +16,14 @@ class Line { calculateSlope = () => { if( this.point1.x==this.point1.y && this.point1.y==0 || this.point2.x==this.point2.y && this.point2.y==0){ - throw new Error("missing data") + throw new Error("attribute is undefined") } this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) } calculateNOfLineFunction = () => { - if(this.slope==undefined || this.point1==undefined){ - throw new Error("missing data") + if(this.slope==undefined ){ + this.calculateSlope() } this.n = this.point1.y - this.slope * this.point1.x } @@ -41,6 +41,9 @@ class Line { if(typeof(x)!="number"){ throw new Error('argument must be type number') } + if(!this.n||!this.slope){ + throw new Error("missing argument") + } let y = this.slope * x + this.n return new Point({ x, y }) } @@ -49,6 +52,9 @@ class Line { if(typeof(y)!="number"){ throw new Error('argument must be type number') } + if(!this.n||!this.slope){ + throw new Error("missing argument") + } let x = (y - this.n) / this.slope; return new Point({ x, y }) } diff --git a/modules/ecs6-class/point.js b/modules/ecs6-class/point.js index b6c099d..3dbf4df 100644 --- a/modules/ecs6-class/point.js +++ b/modules/ecs6-class/point.js @@ -1,19 +1,19 @@ class Point { constructor({x=0, y=0}={}) { - if(typeof(x)!="number" || typeof(y)!="number"){ + if(typeof(x)!=="number" || typeof(y)!=="number"){ throw new Error('argument must be type number') } this.x = x; this.y = y; } moveVertical(value) { - if(typeof(value)!="number"){ + if(typeof(value)!=="number"){ throw new Error('argument must be type number') } this.y += value; } moveHorizontal(value) { - if(typeof(value)!="number"){ + if(typeof(value)!=="number"){ throw new Error('argument must be type number') } this.x += value; diff --git a/modules/geometry-calculation.js b/modules/geometry-calculation.js index ed4c6b6..0932bb2 100644 --- a/modules/geometry-calculation.js +++ b/modules/geometry-calculation.js @@ -5,10 +5,9 @@ const calculateDistance = (point1, point2) => { if (!point1 || !point2) { throw new Error('missing data') } - if (typeof (point1) != 'object' | typeof (point2) != 'object') { + if (!(point1 instanceof Point) || !(point2 instanceof Point )) { throw new Error('argument must by type point') } - let distanceX = (point2.x - point1.x) ** 2; let distanceY = (point2.y - point1.y) ** 2; const distance = Math.sqrt(distanceX + distanceY); diff --git a/package-lock.json b/package-lock.json index 61f4a09..ad0be03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,10 @@ "license": "ISC", "dependencies": { "jest": "^29.7.0" + }, + "devDependencies": { + "axios": "^1.7.2", + "msw": "^2.3.2" } }, "node_modules/@ampproject/remapping": { @@ -487,6 +491,108 @@ "version": "0.2.3", "license": "MIT" }, + "node_modules/@bundled-es-modules/cookie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.0.tgz", + "integrity": "sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==", + "dev": true, + "dependencies": { + "cookie": "^0.5.0" + } + }, + "node_modules/@bundled-es-modules/statuses": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz", + "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==", + "dev": true, + "dependencies": { + "statuses": "^2.0.1" + } + }, + "node_modules/@inquirer/confirm": { + "version": "3.1.17", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.1.17.tgz", + "integrity": "sha512-qCpt/AABzPynz8tr69VDvhcjwmzAryipWXtW8Vi6m651da4H/d0Bdn55LkxXD7Rp2gfgxvxzTdb66AhIA8gzBA==", + "dev": true, + "dependencies": { + "@inquirer/core": "^9.0.5", + "@inquirer/type": "^1.5.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.0.5.tgz", + "integrity": "sha512-QWG41I7vn62O9stYKg/juKXt1PEbr/4ZZCPb4KgXDQGwgA9M5NBTQ7FnOvT1ridbxkm/wTxLCNraUs7y47pIRQ==", + "dev": true, + "dependencies": { + "@inquirer/figures": "^1.0.5", + "@inquirer/type": "^1.5.1", + "@types/mute-stream": "^0.0.4", + "@types/node": "^20.14.11", + "@types/wrap-ansi": "^3.0.0", + "ansi-escapes": "^4.3.2", + "cli-spinners": "^2.9.2", + "cli-width": "^4.1.0", + "mute-stream": "^1.0.0", + "signal-exit": "^4.1.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@inquirer/core/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@inquirer/figures": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.5.tgz", + "integrity": "sha512-79hP/VWdZ2UVc9bFGJnoQ/lQMpL74mGgzSYX1xUqCVk7/v73vJCMw1VuyWN1jGkZ9B3z7THAbySqGbCNefcjfA==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/type": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.5.1.tgz", + "integrity": "sha512-m3YgGQlKNS0BM+8AFiJkCsTqHEFCWn6s/Rqye3mYwvqY6LdfUv12eSwbsgNzrYyrLXiy7IrrjDLPysaSBwEfhw==", + "dev": true, + "dependencies": { + "mute-stream": "^1.0.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "license": "ISC", @@ -796,6 +902,54 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mswjs/cookies": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@mswjs/cookies/-/cookies-1.1.1.tgz", + "integrity": "sha512-W68qOHEjx1iD+4VjQudlx26CPIoxmIAtK4ZCexU0/UJBG6jYhcuyzKJx+Iw8uhBIGd9eba64XgWVgo20it1qwA==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@mswjs/interceptors": { + "version": "0.29.1", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.29.1.tgz", + "integrity": "sha512-3rDakgJZ77+RiQUuSK69t1F0m8BQKA8Vh5DCS5V0DWvNY67zob2JhhQrhCO0AKLGINTRSFd1tBaHcJTkhefoSw==", + "dev": true, + "dependencies": { + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/logger": "^0.3.0", + "@open-draft/until": "^2.0.0", + "is-node-process": "^1.2.0", + "outvariant": "^1.2.1", + "strict-event-emitter": "^0.5.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@open-draft/deferred-promise": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", + "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", + "dev": true + }, + "node_modules/@open-draft/logger": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", + "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "dev": true, + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + } + }, + "node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", + "dev": true + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "license": "MIT" @@ -847,6 +1001,12 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", + "dev": true + }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "license": "MIT", @@ -872,9 +1032,19 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/mute-stream": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz", + "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/node": { - "version": "20.11.30", - "license": "MIT", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "dependencies": { "undici-types": "~5.26.4" } @@ -883,6 +1053,18 @@ "version": "2.0.3", "license": "MIT" }, + "node_modules/@types/statuses": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", + "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==", + "dev": true + }, + "node_modules/@types/wrap-ansi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz", + "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.32", "license": "MIT", @@ -945,6 +1127,23 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-jest": { "version": "29.7.0", "license": "MIT", @@ -1173,6 +1372,27 @@ "version": "1.2.3", "license": "MIT" }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, "node_modules/cliui": { "version": "8.0.1", "license": "ISC", @@ -1211,6 +1431,18 @@ "version": "1.1.4", "license": "MIT" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "license": "MIT" @@ -1219,6 +1451,15 @@ "version": "2.0.0", "license": "MIT" }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/create-jest": { "version": "29.7.0", "license": "MIT", @@ -1284,6 +1525,15 @@ "node": ">=0.10.0" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "license": "MIT", @@ -1421,6 +1671,40 @@ "node": ">=8" } }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "license": "ISC" @@ -1492,6 +1776,15 @@ "version": "4.2.11", "license": "ISC" }, + "node_modules/graphql": { + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, "node_modules/has-flag": { "version": "4.0.0", "license": "MIT", @@ -1509,6 +1802,12 @@ "node": ">= 0.4" } }, + "node_modules/headers-polyfill": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz", + "integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==", + "dev": true + }, "node_modules/html-escaper": { "version": "2.0.2", "license": "MIT" @@ -1584,6 +1883,12 @@ "node": ">=6" } }, + "node_modules/is-node-process": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", + "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", + "dev": true + }, "node_modules/is-number": { "version": "7.0.0", "license": "MIT", @@ -2351,6 +2656,27 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "license": "MIT", @@ -2372,6 +2698,70 @@ "version": "2.1.2", "license": "MIT" }, + "node_modules/msw": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/msw/-/msw-2.3.2.tgz", + "integrity": "sha512-vDn6d6a50vxPE+HnaKQfpmZ4SVXlOjF97yD5FJcUT3v2/uZ65qvTYNL25yOmnrfCNWZ4wtAS7EbtXxygMug2Tw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@bundled-es-modules/cookie": "^2.0.0", + "@bundled-es-modules/statuses": "^1.0.1", + "@inquirer/confirm": "^3.0.0", + "@mswjs/cookies": "^1.1.0", + "@mswjs/interceptors": "^0.29.0", + "@open-draft/until": "^2.1.0", + "@types/cookie": "^0.6.0", + "@types/statuses": "^2.0.4", + "chalk": "^4.1.2", + "graphql": "^16.8.1", + "headers-polyfill": "^4.0.2", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.2", + "path-to-regexp": "^6.2.0", + "strict-event-emitter": "^0.5.1", + "type-fest": "^4.9.0", + "yargs": "^17.7.2" + }, + "bin": { + "msw": "cli/index.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/mswjs" + }, + "peerDependencies": { + "typescript": ">= 4.7.x" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/msw/node_modules/type-fest": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.22.1.tgz", + "integrity": "sha512-9tHNEa0Ov81YOopiVkcCJVz5TM6AEQ+CHHjFIktqPnE3NV0AHIkx+gh9tiCl58m/66wWxkOC9eltpa75J4lQPA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "license": "MIT" @@ -2421,6 +2811,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/outvariant": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", + "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", + "dev": true + }, "node_modules/p-limit": { "version": "3.1.0", "license": "MIT", @@ -2505,6 +2901,12 @@ "version": "1.0.7", "license": "MIT" }, + "node_modules/path-to-regexp": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.2.tgz", + "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==", + "dev": true + }, "node_modules/picocolors": { "version": "1.0.0", "license": "ISC" @@ -2569,6 +2971,12 @@ "node": ">= 6" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/pure-rand": { "version": "6.1.0", "funding": [ @@ -2701,6 +3109,21 @@ "node": ">=10" } }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/strict-event-emitter": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", + "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", + "dev": true + }, "node_modules/string-length": { "version": "4.0.2", "license": "MIT", @@ -2965,6 +3388,18 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/yoctocolors-cjs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz", + "integrity": "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index 355814a..aa6589b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,11 @@ "dependencies": { "jest": "^29.7.0" }, + "devDependencies": { + "msw":"^2.3.2", + "axios": "^1.7.2" + } + , "repository": { "type": "git", "url": "git+https://github.com/gemtechd/build-tests.git" From 07741f2477d7aa888c2edb5905566ee9b07d8bbc Mon Sep 17 00:00:00 2001 From: "m.mendelsohn" Date: Tue, 23 Jul 2024 16:05:42 +0300 Subject: [PATCH 3/6] add test --- tests/modules/ecs6-class/line.test.js | 138 +++++++++++++++++++++ tests/modules/ecs6-class/point.test.js | 47 +++++++ tests/modules/geometry-calculation.test.js | 115 +++++++++++++++++ 3 files changed, 300 insertions(+) create mode 100644 tests/modules/ecs6-class/line.test.js create mode 100644 tests/modules/ecs6-class/point.test.js create mode 100644 tests/modules/geometry-calculation.test.js diff --git a/tests/modules/ecs6-class/line.test.js b/tests/modules/ecs6-class/line.test.js new file mode 100644 index 0000000..40badcb --- /dev/null +++ b/tests/modules/ecs6-class/line.test.js @@ -0,0 +1,138 @@ +const Line = require("../../../modules/ecs6-class/line"); +const Point = require("../../../modules/ecs6-class/point"); + + +describe("LINE", function () { + it("should return point1 of line", function () { + const x = new Line({ point1: new Point({ x: 2, y: 3 }), point2: new Point({ x: 2, y: 3 }) }) + expect(x.point1).toStrictEqual(new Point({ x: 2, y: 3 })); + }) + describe("CALCULATE_SLOPE", function () { + it("should return slope of line", function () { + const poix = new Point({ x: 3, y: 4 }); + const poiy = new Point({ x: 1, y: 3 }); + const li1 = new Line({ point1: poix, point2: poiy }) + li1.calculateSlope() + expect(li1.slope).toBe(0.5); + }) + }) + + describe("CALCULATE_N_OF_LINE_FUNCTION", function () { + it("should return n of line", function () { + const poix = new Point({ x: 3, y: 4 }); + const poiy = new Point({ x: 1, y: 3 }); + const li1 = new Line({ point1: poix, point2: poiy }) + li1.calculateSlope() + li1.calculateNOfLineFunction() + expect(li1.n).toBe(2.5); + }) + it("should return n of line if slope is undeined", function () { + const poix = new Point({ x: 3, y: 4 }); + const poiy = new Point({ x: 5, y: 7 }); + const li1 = new Line({ point1: poix, point2: poiy }) + li1.calculateNOfLineFunction() + expect(li1.n).toBe(-0.5) + }) + }) + + + + describe("GET_POINT_ON_Y_ASIS", function () { + it("should return a new point on y axis", function () { + const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) + x.calculateSlope() + x.calculateNOfLineFunction() + expect(x.getPointOnYAsis()).toStrictEqual(new Point({ x: 0, y: 9 })); + }) + }) + + + describe("GET_POINT_ON_X_ASIS", function () { + it("should return a new point on x axis", function () { + const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) + x.calculateSlope() + x.calculateNOfLineFunction() + expect(x.getPointOnXAsis()).toStrictEqual(new Point({ x: 3, y: 0 })); + }) + }) + describe("GET_POINT_BY_X", function () { + it("function get Point By X", function () { + let li1 = new Line({ n: 7, slope: 2 }) + expect(li1.getPointByX(6)).toEqual({ x: 6, y: 19 }) + }) + }) + describe("GET_POINT_BY_Y", function () { + it("function get Point By Y", function () { + let li1 = new Line({ n: 7, slope: 2 }) + expect(li1.getPointByY(3)).toEqual({ x: -2, y: 3 }) + }) + + }) + describe("EERORS", function () { + const poix = new Point({ x: 3, y: 4 }); + + it("should return error if argument is not Point", function () { + expect(function () { new Line({ point1: "rtry" }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point1: true }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point1: () => { } }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point1: { id: 1 } }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point1: [1, 2, 3] }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point2: "rtry" }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point2: true }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point2: () => { } }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point2: [1, 2, 3] }) }).toThrow(new Error("argument must be type point")) + expect(function () { new Line({ point2: { id: 1, name: 8 } }) }).toThrow(new Error("argument must be type point")) + }) + it("should return error if argument is not number", function () { + expect(function () { new Line({ point1: poix, point2: poix, n: "rtry", slope: 9 }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: true, slope: 9 }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: () => { } }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: [1, 2] }) }).toThrow(new Error("argument must be type number")) + + + }) + describe('CALCULATE SLOPE', function () { + it("should return error if attribute is undefined", function () { + const li1 = new Line({ point1: poix, n: 6, slope: 9 }) + expect(function () { li1.calculateSlope() }).toThrow(new Error("attribute is undefined")) + }) + it("should return error if attribute is undefined", function () { + const li1 = new Line({ point2: poix, n: 6, slope: 9 }) + expect(function () { li1.calculateSlope() }).toThrow(new Error("attribute is undefined")) + }) + }) + + describe('GET POINT BY X', function () { + it("should return error if argument is not number", function () { + const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) + expect(function () { x.getPointByX("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByX(true) }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByX(() => { }) }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByX([1, 2]) }).toThrow(new Error("argument must be type number")) + }) + it("should return error if missing attribute", function () { + let li1 = new Line({ n: 7 }) + let li2 = new Line({ slope: 7 }) + expect(function(){li1.getPointByX(3)}).toThrow(new Error("missing argument")) + expect(function(){li2.getPointByX(3)}).toThrow(new Error("missing argument")) + + }) + }) + describe('GET POINT BY Y', function () { + it("should return error if argument is not number", function () { + const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) + expect(function () { x.getPointByY("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByY(true) }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByY(() => { }) }).toThrow(new Error("argument must be type number")) + expect(function () { x.getPointByY([1, 2]) }).toThrow(new Error("argument must be type number")) + }) + it("should return error if missing attribute", function () { + let li1 = new Line({ n: 7 }) + let li2 = new Line({ slope: 7 }) + expect(function(){li1.getPointByY(3)}).toThrow(new Error("missing argument")) + expect(function(){li2.getPointByY(3)}).toThrow(new Error("missing argument")) + + }) + }) + }) +}); diff --git a/tests/modules/ecs6-class/point.test.js b/tests/modules/ecs6-class/point.test.js new file mode 100644 index 0000000..c49331d --- /dev/null +++ b/tests/modules/ecs6-class/point.test.js @@ -0,0 +1,47 @@ +const Point = require("../../../modules/ecs6-class/point"); + +describe("POINT", function () { + it("should return the value x of point", function () { + const px=new Point({x:4,y:3}) + expect(px.x).toBe(4); + }) + it("should return the value x of point after the move horizontal", function () { + const px=new Point({x:4,y:3}) + px.moveHorizontal(3) + expect(px.x).toBe(7); + }) + it("should return the value x of point after the move vertical", function () { + const px=new Point({x:4,y:3}) + px.moveVertical(2) + expect(px.y).toBe(5); + }) + describe("EERORS", function () { + it("should return error if argument is not number", function () { + expect(function () { new Point({x:"rtry"}) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({x:true}) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({x:()=>{}}) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({x:[1,2]}) }).toThrow(new Error("argument must be type number")) + }) + + }) + describe("MOVE VERTICAL",function(){ + it("should return error if argument is not number", function () { + const px=new Point({x:1,y:6}) + expect(function () { px.moveVertical("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical(true) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical(()=>{}) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical([1,2]) }).toThrow(new Error("argument must be type number")) + }) + }) + + describe("MOVE HORIZONTAL",function(){ + it("should return error if argument is not number", function () { + const px=new Point({x:1,y:6}) + expect(function () { px.moveHorizontal("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal(true) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal(()=>{}) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal([1,2]) }).toThrow(new Error("argument must be type number")) + }) + }) + +}); diff --git a/tests/modules/geometry-calculation.test.js b/tests/modules/geometry-calculation.test.js new file mode 100644 index 0000000..b5a35f9 --- /dev/null +++ b/tests/modules/geometry-calculation.test.js @@ -0,0 +1,115 @@ + +const Line = require("../../modules/ecs6-class/line"); +const Point = require("../../modules/ecs6-class/point"); +const { calculateDistance, calculateJunctionPoint, isPointOnLine } = require("../../modules/geometry-calculation") + +describe("CALCULATE_DISTANCE", function () { + it("should return the distance between 2 points", function () { + const x = new Point({ x: 4, y: 3 }) + const y = new Point({ x: 5, y: 6 }) + expect(calculateDistance(x, y)).toBe(3.1622776601683795); + }) + it("should return 0 if the 2 points is same", function () { + const x = new Point({ x: 5, y: 3 }) + expect(calculateDistance(x, x)).toBe(0); + }) + describe("EERORS", function () { + it("should return error if not get 2 points", function () { + expect(function () { calculateDistance(new Point({ x: 4, y: 3 })) }).toThrow(new Error("missing data")); + + }) + it("should return error if not get attribute", function () { + expect(function () { calculateDistance() }).toThrow(new Error("missing data")) + }) + it("should return error if argument is not number", function () { + expect(function () { calculateDistance("rtry", 9) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(true, 9) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(() => { }, 9) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(1.8, 9) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(2, "uioyi") }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(2,[1,2,3]) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance([1,2,3], 1) }).toThrow(new Error("argument must by type point")) + + }) + + }) + + +}); + + +describe("CALCULATE_JUNCTION_POINT", function () { + it("should returen a junction point ", function () { + const px = new Point({ x: 4, y: 3 }) + const py = new Point({ x: 5, y: 6 }) + const pz = new Point({ x: 3, y: 7 }) + const line1 = new Line({ point1: px, point2: py }) + const line2 = new Line({ point1: py, point2: pz }) + line1.calculateSlope() + line1.calculateNOfLineFunction() + line2.calculateSlope() + line2.calculateNOfLineFunction() + expect(calculateJunctionPoint(line1, line2)).toStrictEqual(new Point({ x: 5, y: 6 })); + }) + it("should returen false if not contain a junction point ", function () { + const line1 = new Line({ n: 4 }) + const line2 = new Line({ n: 6 }) + expect(calculateJunctionPoint(line1, line2)).toBe(false); + }) + it("should returen true if n in line is same ", function () { + const x = new Point({ x: 4, y: 3 }) + const y = new Point({ x: 5, y: 6 }) + const line1 = new Line({ x, y }) + expect(calculateJunctionPoint(line1, line1)).toBe(true); + }) + + describe("EERORS", function () { + it("should returen error if not get 2 points", function () { + const x = new Point({ x: 4, y: 3 }) + expect(function () { calculateJunctionPoint(x) }).toThrow("missing data") + }) + it("should returen error in not get attribute", function () { + expect(function () { calculateJunctionPoint() }).toThrow("missing data") + }) + }) + + +}); + +describe("IS_POINT_IN_LINE", function () { + it("should returen true if point on line", function () { + const px = new Point({ x: 4, y: 3 }) + const py = new Point({ x: 5, y: 6 }) + const line1 = new Line({ point1: px, point2: py }) + line1.calculateSlope() + line1.calculateNOfLineFunction() + expect(isPointOnLine(line1, py)).toBe(true); + }) + it("should returen false if n of point no same n of new point", function () { + const px = new Point({ x: 4, y: 16 }) + const py = new Point({ x: 3, y: 9 }) + const pz = new Point({ x: 2, y: 2 }) + const line1 = new Line({ point1: px, point2: py, n: 6 }) + line1.calculateSlope() + expect(isPointOnLine(line1, pz)).toBe(false); + }) + it("should returen false if point no on line", function () { + const px = new Point({ x: 4, y: 3 }) + const py = new Point({ x: 5, y: 6 }) + const pz = new Point({ x: 1, y: 2 }) + const line1 = new Line({ point1: px, point2: py }) + line1.calculateSlope() + line1.calculateNOfLineFunction() + expect(isPointOnLine(line1, pz)).toBe(false); + }) + + describe("EERORS", function () { + it("should returen error if not get 2 points", function () { + const x = new Point({ x: 4, y: 3 }) + expect(function(){isPointOnLine(x)}).toThrow("missing data") + }) + it("should returen error in not get attribute", function () { + expect(function(){isPointOnLine()}).toThrow("missing data") + }) + }) +}); From 2a56c703f1c59b991a9537e6b3f05e462153d211 Mon Sep 17 00:00:00 2001 From: "m.mendelsohn" Date: Wed, 24 Jul 2024 09:07:29 +0300 Subject: [PATCH 4/6] correct tests --- modules/geometry-calculation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/geometry-calculation.js b/modules/geometry-calculation.js index 0932bb2..b5a2e8c 100644 --- a/modules/geometry-calculation.js +++ b/modules/geometry-calculation.js @@ -34,7 +34,7 @@ const calculateJunctionPoint = (line1, line2) => { } const isPointOnLine = (line, point) => { - if (line == undefined || point == undefined) { + if (!line||!line.slope ||!line.n|| !point ) { throw new Error("missing data") } const proxyLine = new Line({ point1: line.point1, point2: point }) From 714fbeb2cbff0e0a7fd780d7c5a8ebb3bab11c46 Mon Sep 17 00:00:00 2001 From: "m.mendelsohn" Date: Wed, 24 Jul 2024 10:29:06 +0300 Subject: [PATCH 5/6] experience --- modules/ecs6-class/line.js | 24 +++++----- modules/ecs6-class/point.js | 8 ++-- modules/geometry-calculation.js | 4 +- package.json | 10 ++--- tests/modules/ecs6-class/line.test.js | 10 ++--- tests/modules/ecs6-class/point.test.js | 52 +++++++++++----------- tests/modules/geometry-calculation.test.js | 8 ++-- 7 files changed, 57 insertions(+), 59 deletions(-) diff --git a/modules/ecs6-class/line.js b/modules/ecs6-class/line.js index ad44480..e846368 100644 --- a/modules/ecs6-class/line.js +++ b/modules/ecs6-class/line.js @@ -2,10 +2,10 @@ const Point = require("./point"); class Line { constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { - if(!(point1 instanceof Point)|| !(point2 instanceof Point)){ + if (!(point1 instanceof Point) || !(point2 instanceof Point)) { throw new Error('argument must be type point') } - if (typeof(n)!="number"&& n !==undefined|| typeof(slope)!=="number" && slope !=undefined){ + if (typeof (n) != "number" && n !== undefined || typeof (slope) !== "number" && slope != undefined) { throw new Error('argument must be type number') } this.point1 = point1; @@ -15,14 +15,14 @@ class Line { } calculateSlope = () => { - if( this.point1.x==this.point1.y && this.point1.y==0 || this.point2.x==this.point2.y && this.point2.y==0){ + if (this.point1.x == this.point1.y && this.point1.y == 0 || this.point2.x == this.point2.y && this.point2.y == 0) { throw new Error("attribute is undefined") } this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) } calculateNOfLineFunction = () => { - if(this.slope==undefined ){ + if (this.slope == undefined) { this.calculateSlope() } this.n = this.point1.y - this.slope * this.point1.x @@ -38,23 +38,23 @@ class Line { getPointByX(x) { - if(typeof(x)!="number"){ + if (typeof (x) != "number") { throw new Error('argument must be type number') } - if(!this.n||!this.slope){ - throw new Error("missing argument") - } + if (!this.n || !this.slope) { + throw new Error("missing argument") + } let y = this.slope * x + this.n return new Point({ x, y }) } getPointByY(y) { - if(typeof(y)!="number"){ + if (typeof (y) != "number") { throw new Error('argument must be type number') } - if(!this.n||!this.slope){ - throw new Error("missing argument") - } + if (!this.n || !this.slope) { + throw new Error("missing argument") + } let x = (y - this.n) / this.slope; return new Point({ x, y }) } diff --git a/modules/ecs6-class/point.js b/modules/ecs6-class/point.js index 3dbf4df..18e6448 100644 --- a/modules/ecs6-class/point.js +++ b/modules/ecs6-class/point.js @@ -1,19 +1,19 @@ class Point { - constructor({x=0, y=0}={}) { - if(typeof(x)!=="number" || typeof(y)!=="number"){ + constructor({ x = 0, y = 0 } = {}) { + if (typeof (x) !== "number" || typeof (y) !== "number") { throw new Error('argument must be type number') } this.x = x; this.y = y; } moveVertical(value) { - if(typeof(value)!=="number"){ + if (typeof (value) !== "number") { throw new Error('argument must be type number') } this.y += value; } moveHorizontal(value) { - if(typeof(value)!=="number"){ + if (typeof (value) !== "number") { throw new Error('argument must be type number') } this.x += value; diff --git a/modules/geometry-calculation.js b/modules/geometry-calculation.js index b5a2e8c..5bf9c69 100644 --- a/modules/geometry-calculation.js +++ b/modules/geometry-calculation.js @@ -5,7 +5,7 @@ const calculateDistance = (point1, point2) => { if (!point1 || !point2) { throw new Error('missing data') } - if (!(point1 instanceof Point) || !(point2 instanceof Point )) { + if (!(point1 instanceof Point) || !(point2 instanceof Point)) { throw new Error('argument must by type point') } let distanceX = (point2.x - point1.x) ** 2; @@ -34,7 +34,7 @@ const calculateJunctionPoint = (line1, line2) => { } const isPointOnLine = (line, point) => { - if (!line||!line.slope ||!line.n|| !point ) { + if (!line || !line.slope || !line.n || !point) { throw new Error("missing data") } const proxyLine = new Line({ point1: line.point1, point2: point }) diff --git a/package.json b/package.json index aa6589b..432214a 100644 --- a/package.json +++ b/package.json @@ -5,16 +5,15 @@ "main": "index.js", "scripts": { "test": "jest", - "test:coverage":"jest --coverage" + "test:coverage": "jest --coverage" }, "dependencies": { "jest": "^29.7.0" }, "devDependencies": { - "msw":"^2.3.2", + "msw": "^2.3.2", "axios": "^1.7.2" - } - , + }, "repository": { "type": "git", "url": "git+https://github.com/gemtechd/build-tests.git" @@ -25,5 +24,4 @@ "homepage": "https://github.com/gemtechd/build-tests#readme", "author": "gemtechd", "license": "ISC" - -} +} \ No newline at end of file diff --git a/tests/modules/ecs6-class/line.test.js b/tests/modules/ecs6-class/line.test.js index 40badcb..271a7ca 100644 --- a/tests/modules/ecs6-class/line.test.js +++ b/tests/modules/ecs6-class/line.test.js @@ -66,7 +66,7 @@ describe("LINE", function () { let li1 = new Line({ n: 7, slope: 2 }) expect(li1.getPointByY(3)).toEqual({ x: -2, y: 3 }) }) - + }) describe("EERORS", function () { const poix = new Point({ x: 3, y: 4 }); @@ -113,8 +113,8 @@ describe("LINE", function () { it("should return error if missing attribute", function () { let li1 = new Line({ n: 7 }) let li2 = new Line({ slope: 7 }) - expect(function(){li1.getPointByX(3)}).toThrow(new Error("missing argument")) - expect(function(){li2.getPointByX(3)}).toThrow(new Error("missing argument")) + expect(function () { li1.getPointByX(3) }).toThrow(new Error("missing argument")) + expect(function () { li2.getPointByX(3) }).toThrow(new Error("missing argument")) }) }) @@ -129,8 +129,8 @@ describe("LINE", function () { it("should return error if missing attribute", function () { let li1 = new Line({ n: 7 }) let li2 = new Line({ slope: 7 }) - expect(function(){li1.getPointByY(3)}).toThrow(new Error("missing argument")) - expect(function(){li2.getPointByY(3)}).toThrow(new Error("missing argument")) + expect(function () { li1.getPointByY(3) }).toThrow(new Error("missing argument")) + expect(function () { li2.getPointByY(3) }).toThrow(new Error("missing argument")) }) }) diff --git a/tests/modules/ecs6-class/point.test.js b/tests/modules/ecs6-class/point.test.js index c49331d..daa25a2 100644 --- a/tests/modules/ecs6-class/point.test.js +++ b/tests/modules/ecs6-class/point.test.js @@ -2,46 +2,46 @@ const Point = require("../../../modules/ecs6-class/point"); describe("POINT", function () { it("should return the value x of point", function () { - const px=new Point({x:4,y:3}) + const px = new Point({ x: 4, y: 3 }) expect(px.x).toBe(4); - }) + }) it("should return the value x of point after the move horizontal", function () { - const px=new Point({x:4,y:3}) + const px = new Point({ x: 4, y: 3 }) px.moveHorizontal(3) expect(px.x).toBe(7); }) it("should return the value x of point after the move vertical", function () { - const px=new Point({x:4,y:3}) + const px = new Point({ x: 4, y: 3 }) px.moveVertical(2) expect(px.y).toBe(5); }) describe("EERORS", function () { it("should return error if argument is not number", function () { - expect(function () { new Point({x:"rtry"}) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({x:true}) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({x:()=>{}}) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({x:[1,2]}) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({ x: "rtry" }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({ x: true }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({ x: () => { } }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({ x: [1, 2] }) }).toThrow(new Error("argument must be type number")) }) - }) - describe("MOVE VERTICAL",function(){ - it("should return error if argument is not number", function () { - const px=new Point({x:1,y:6}) - expect(function () { px.moveVertical("ret") }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveVertical(true) }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveVertical(()=>{}) }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveVertical([1,2]) }).toThrow(new Error("argument must be type number")) - }) + }) + describe("MOVE VERTICAL", function () { + it("should return error if argument is not number", function () { + const px = new Point({ x: 1, y: 6 }) + expect(function () { px.moveVertical("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical(true) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical(() => { }) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveVertical([1, 2]) }).toThrow(new Error("argument must be type number")) }) + }) - describe("MOVE HORIZONTAL",function(){ - it("should return error if argument is not number", function () { - const px=new Point({x:1,y:6}) - expect(function () { px.moveHorizontal("ret") }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveHorizontal(true) }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveHorizontal(()=>{}) }).toThrow(new Error("argument must be type number")) - expect(function () { px.moveHorizontal([1,2]) }).toThrow(new Error("argument must be type number")) - }) + describe("MOVE HORIZONTAL", function () { + it("should return error if argument is not number", function () { + const px = new Point({ x: 1, y: 6 }) + expect(function () { px.moveHorizontal("ret") }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal(true) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal(() => { }) }).toThrow(new Error("argument must be type number")) + expect(function () { px.moveHorizontal([1, 2]) }).toThrow(new Error("argument must be type number")) + }) }) - + }); diff --git a/tests/modules/geometry-calculation.test.js b/tests/modules/geometry-calculation.test.js index b5a35f9..b403f9e 100644 --- a/tests/modules/geometry-calculation.test.js +++ b/tests/modules/geometry-calculation.test.js @@ -27,8 +27,8 @@ describe("CALCULATE_DISTANCE", function () { expect(function () { calculateDistance(() => { }, 9) }).toThrow(new Error("argument must by type point")) expect(function () { calculateDistance(1.8, 9) }).toThrow(new Error("argument must by type point")) expect(function () { calculateDistance(2, "uioyi") }).toThrow(new Error("argument must by type point")) - expect(function () { calculateDistance(2,[1,2,3]) }).toThrow(new Error("argument must by type point")) - expect(function () { calculateDistance([1,2,3], 1) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance(2, [1, 2, 3]) }).toThrow(new Error("argument must by type point")) + expect(function () { calculateDistance([1, 2, 3], 1) }).toThrow(new Error("argument must by type point")) }) @@ -106,10 +106,10 @@ describe("IS_POINT_IN_LINE", function () { describe("EERORS", function () { it("should returen error if not get 2 points", function () { const x = new Point({ x: 4, y: 3 }) - expect(function(){isPointOnLine(x)}).toThrow("missing data") + expect(function () { isPointOnLine(x) }).toThrow("missing data") }) it("should returen error in not get attribute", function () { - expect(function(){isPointOnLine()}).toThrow("missing data") + expect(function () { isPointOnLine() }).toThrow("missing data") }) }) }); From 436dadaaa0b25f242c09adbafb1ffa4c9fc3e195 Mon Sep 17 00:00:00 2001 From: "m.mendelsohn" Date: Sun, 28 Jul 2024 12:12:58 +0300 Subject: [PATCH 6/6] fix test --- modules/ecs6-class/line.js | 17 ++++---- modules/ecs6-class/point.js | 7 +++- tests/modules/ecs6-class/line.test.js | 45 +++++++--------------- tests/modules/ecs6-class/point.test.js | 21 +++++++--- tests/modules/geometry-calculation.test.js | 14 +------ 5 files changed, 46 insertions(+), 58 deletions(-) diff --git a/modules/ecs6-class/line.js b/modules/ecs6-class/line.js index e846368..ccdcc01 100644 --- a/modules/ecs6-class/line.js +++ b/modules/ecs6-class/line.js @@ -5,8 +5,11 @@ class Line { if (!(point1 instanceof Point) || !(point2 instanceof Point)) { throw new Error('argument must be type point') } - if (typeof (n) != "number" && n !== undefined || typeof (slope) !== "number" && slope != undefined) { - throw new Error('argument must be type number') + if (typeof (n) != "number" && n !== undefined) { + throw new Error('argument n must be type number') + } + if (typeof (slope) !== "number" && slope != undefined) { + throw new Error('argument slope must be type number') } this.point1 = point1; this.point2 = point2; @@ -15,9 +18,6 @@ class Line { } calculateSlope = () => { - if (this.point1.x == this.point1.y && this.point1.y == 0 || this.point2.x == this.point2.y && this.point2.y == 0) { - throw new Error("attribute is undefined") - } this.slope = (this.point1.y - this.point2.y) / (this.point1.x - this.point2.x) } @@ -41,8 +41,11 @@ class Line { if (typeof (x) != "number") { throw new Error('argument must be type number') } - if (!this.n || !this.slope) { - throw new Error("missing argument") + if (!this.n) { + this.calculateNOfLineFunction() + } + if (!this.slope) { + this.calculateSlope() } let y = this.slope * x + this.n return new Point({ x, y }) diff --git a/modules/ecs6-class/point.js b/modules/ecs6-class/point.js index 18e6448..ca3f6f9 100644 --- a/modules/ecs6-class/point.js +++ b/modules/ecs6-class/point.js @@ -1,7 +1,10 @@ class Point { constructor({ x = 0, y = 0 } = {}) { - if (typeof (x) !== "number" || typeof (y) !== "number") { - throw new Error('argument must be type number') + if (typeof (x) !== "number") { + throw new Error('argument x must be type number') + } + if (typeof (y) !== "number") { + throw new Error('argument y must be type number') } this.x = x; this.y = y; diff --git a/tests/modules/ecs6-class/line.test.js b/tests/modules/ecs6-class/line.test.js index 271a7ca..bda53d7 100644 --- a/tests/modules/ecs6-class/line.test.js +++ b/tests/modules/ecs6-class/line.test.js @@ -21,9 +21,7 @@ describe("LINE", function () { it("should return n of line", function () { const poix = new Point({ x: 3, y: 4 }); const poiy = new Point({ x: 1, y: 3 }); - const li1 = new Line({ point1: poix, point2: poiy }) - li1.calculateSlope() - li1.calculateNOfLineFunction() + const li1 = new Line({ point1: poix, point2: poiy, slope: 0.5, n: 2.5 }) expect(li1.n).toBe(2.5); }) it("should return n of line if slope is undeined", function () { @@ -35,8 +33,6 @@ describe("LINE", function () { }) }) - - describe("GET_POINT_ON_Y_ASIS", function () { it("should return a new point on y axis", function () { const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) @@ -46,7 +42,6 @@ describe("LINE", function () { }) }) - describe("GET_POINT_ON_X_ASIS", function () { it("should return a new point on x axis", function () { const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) @@ -60,17 +55,23 @@ describe("LINE", function () { let li1 = new Line({ n: 7, slope: 2 }) expect(li1.getPointByX(6)).toEqual({ x: 6, y: 19 }) }) + it("should calculate the values of the missing data", function () { + const poix = new Point({ x: 1, y: 5 }); + const poiy = new Point({ x: 5, y: 1 }); + let li1 = new Line({ point1: poix, point2: poiy, n: 7 }) + let li2 = new Line({ point1: poix, point2: poiy, slope: 7 }) + expect(li2.getPointByX(3)).toStrictEqual(new Point({ x: 3, y: 19 })) + expect(li1.getPointByX(3)).toStrictEqual(new Point({ x: 3, y: 4 })) + }) }) describe("GET_POINT_BY_Y", function () { it("function get Point By Y", function () { let li1 = new Line({ n: 7, slope: 2 }) expect(li1.getPointByY(3)).toEqual({ x: -2, y: 3 }) }) - }) describe("EERORS", function () { const poix = new Point({ x: 3, y: 4 }); - it("should return error if argument is not Point", function () { expect(function () { new Line({ point1: "rtry" }) }).toThrow(new Error("argument must be type point")) expect(function () { new Line({ point1: true }) }).toThrow(new Error("argument must be type point")) @@ -84,24 +85,11 @@ describe("LINE", function () { expect(function () { new Line({ point2: { id: 1, name: 8 } }) }).toThrow(new Error("argument must be type point")) }) it("should return error if argument is not number", function () { - expect(function () { new Line({ point1: poix, point2: poix, n: "rtry", slope: 9 }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Line({ point1: poix, point2: poix, n: true, slope: 9 }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: () => { } }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: [1, 2] }) }).toThrow(new Error("argument must be type number")) - - + expect(function () { new Line({ point1: poix, point2: poix, n: "rtry", slope: 9 }) }).toThrow(new Error("argument n must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: true, slope: 9 }) }).toThrow(new Error("argument n must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: () => { } }) }).toThrow(new Error("argument slope must be type number")) + expect(function () { new Line({ point1: poix, point2: poix, n: 8, slope: [1, 2] }) }).toThrow(new Error("argument slope must be type number")) }) - describe('CALCULATE SLOPE', function () { - it("should return error if attribute is undefined", function () { - const li1 = new Line({ point1: poix, n: 6, slope: 9 }) - expect(function () { li1.calculateSlope() }).toThrow(new Error("attribute is undefined")) - }) - it("should return error if attribute is undefined", function () { - const li1 = new Line({ point2: poix, n: 6, slope: 9 }) - expect(function () { li1.calculateSlope() }).toThrow(new Error("attribute is undefined")) - }) - }) - describe('GET POINT BY X', function () { it("should return error if argument is not number", function () { const x = new Line({ point1: new Point({ x: 1, y: 6 }), point2: new Point({ x: 2, y: 3 }) }) @@ -110,13 +98,6 @@ describe("LINE", function () { expect(function () { x.getPointByX(() => { }) }).toThrow(new Error("argument must be type number")) expect(function () { x.getPointByX([1, 2]) }).toThrow(new Error("argument must be type number")) }) - it("should return error if missing attribute", function () { - let li1 = new Line({ n: 7 }) - let li2 = new Line({ slope: 7 }) - expect(function () { li1.getPointByX(3) }).toThrow(new Error("missing argument")) - expect(function () { li2.getPointByX(3) }).toThrow(new Error("missing argument")) - - }) }) describe('GET POINT BY Y', function () { it("should return error if argument is not number", function () { diff --git a/tests/modules/ecs6-class/point.test.js b/tests/modules/ecs6-class/point.test.js index daa25a2..673407d 100644 --- a/tests/modules/ecs6-class/point.test.js +++ b/tests/modules/ecs6-class/point.test.js @@ -1,10 +1,18 @@ const Point = require("../../../modules/ecs6-class/point"); describe("POINT", function () { + it("should return the values of point", function () { + const px = new Point({ x: 4, y: 3 }) + expect(px).toStrictEqual(new Point({ x: 4, y: 3 })) + }) it("should return the value x of point", function () { const px = new Point({ x: 4, y: 3 }) expect(px.x).toBe(4); }) + it("should return the value y of point", function () { + const px = new Point({ x: 4, y: 3 }) + expect(px.y).toBe(3); + }) it("should return the value x of point after the move horizontal", function () { const px = new Point({ x: 4, y: 3 }) px.moveHorizontal(3) @@ -17,10 +25,14 @@ describe("POINT", function () { }) describe("EERORS", function () { it("should return error if argument is not number", function () { - expect(function () { new Point({ x: "rtry" }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({ x: true }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({ x: () => { } }) }).toThrow(new Error("argument must be type number")) - expect(function () { new Point({ x: [1, 2] }) }).toThrow(new Error("argument must be type number")) + expect(function () { new Point({ x: "rtry" }) }).toThrow(new Error("argument x must be type number")) + expect(function () { new Point({ x: true }) }).toThrow(new Error("argument x must be type number")) + expect(function () { new Point({ x: () => { } }) }).toThrow(new Error("argument x must be type number")) + expect(function () { new Point({ x: [1, 2] }) }).toThrow(new Error("argument x must be type number")) + expect(function () { new Point({ y: "rtry" }) }).toThrow(new Error("argument y must be type number")) + expect(function () { new Point({ y: true }) }).toThrow(new Error("argument y must be type number")) + expect(function () { new Point({ y: () => { } }) }).toThrow(new Error("argument y must be type number")) + expect(function () { new Point({ y: [1, 2] }) }).toThrow(new Error("argument y must be type number")) }) }) @@ -43,5 +55,4 @@ describe("POINT", function () { expect(function () { px.moveHorizontal([1, 2]) }).toThrow(new Error("argument must be type number")) }) }) - }); diff --git a/tests/modules/geometry-calculation.test.js b/tests/modules/geometry-calculation.test.js index b403f9e..4dae3dd 100644 --- a/tests/modules/geometry-calculation.test.js +++ b/tests/modules/geometry-calculation.test.js @@ -29,12 +29,8 @@ describe("CALCULATE_DISTANCE", function () { expect(function () { calculateDistance(2, "uioyi") }).toThrow(new Error("argument must by type point")) expect(function () { calculateDistance(2, [1, 2, 3]) }).toThrow(new Error("argument must by type point")) expect(function () { calculateDistance([1, 2, 3], 1) }).toThrow(new Error("argument must by type point")) - }) - }) - - }); @@ -43,12 +39,8 @@ describe("CALCULATE_JUNCTION_POINT", function () { const px = new Point({ x: 4, y: 3 }) const py = new Point({ x: 5, y: 6 }) const pz = new Point({ x: 3, y: 7 }) - const line1 = new Line({ point1: px, point2: py }) - const line2 = new Line({ point1: py, point2: pz }) - line1.calculateSlope() - line1.calculateNOfLineFunction() - line2.calculateSlope() - line2.calculateNOfLineFunction() + const line1 = new Line({ point1: px, point2: py, slope: 3, n: -9 }) + const line2 = new Line({ point1: py, point2: pz, slope: -0.5, n: 8.5 }) expect(calculateJunctionPoint(line1, line2)).toStrictEqual(new Point({ x: 5, y: 6 })); }) it("should returen false if not contain a junction point ", function () { @@ -72,8 +64,6 @@ describe("CALCULATE_JUNCTION_POINT", function () { expect(function () { calculateJunctionPoint() }).toThrow("missing data") }) }) - - }); describe("IS_POINT_IN_LINE", function () {