Skip to content

Commit b6798c4

Browse files
committed
test: add check types
1 parent 2e51a0b commit b6798c4

File tree

5 files changed

+98
-4
lines changed

5 files changed

+98
-4
lines changed

package-lock.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"./package.json": "./package.json"
1414
},
1515
"scripts": {
16-
"all": "run-s lint test",
16+
"all": "run-s lint check-types test",
1717
"lint": "eslint .",
1818
"dev": "npm test -- --auto-watch --no-single-run",
19-
"test": "karma start karma.conf.cjs"
19+
"test": "karma start karma.conf.cjs",
20+
"check-types": "tsc --noEmit"
2021
},
2122
"engines": {
2223
"node": ">= 14.20"
@@ -36,6 +37,9 @@
3637
},
3738
"license": "MIT",
3839
"devDependencies": {
40+
"@types/chai": "^4.3.12",
41+
"@types/karma-chai": "^0.1.6",
42+
"@types/mocha": "^10.0.6",
3943
"chai": "^4.4.1",
4044
"domify": "^2.0.0",
4145
"eslint": "^8.55.0",
@@ -51,6 +55,7 @@
5155
"puppeteer": "^22.4.1",
5256
"sinon": "^17.0.1",
5357
"sinon-chai": "^3.7.0",
58+
"typescript": "^5.4.2",
5459
"webpack": "^5.90.3"
5560
},
5661
"files": [

test/intersect.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ function debug(label, pathArray, intersectionsArray, fail) {
390390
'</g>' +
391391
'</svg>';
392392

393-
var svgNode = domify(svg);
393+
var svgNode = /** @type {SVGElement} */ (domify(svg));
394394

395395
// show debug SVG
396396
document.body.appendChild(svgNode);
397397

398398
// center visible elements group
399-
var group = svgNode.querySelector('g');
399+
var group = /** @type {SVGGElement} */ (svgNode.querySelector('g'));
400400

401401
var bbox = group.getBBox();
402402

test/intersect.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import intersect from 'path-intersection';
2+
3+
import domify from 'domify';
4+
5+
6+
describe('path-intersection', function() {
7+
8+
describe('api', function() {
9+
10+
var p1 = [ [ 'M', 0, 0 ], [ 'L', 100, 100 ] ];
11+
var p2 = 'M0,100L100,0';
12+
13+
14+
it('should support SVG path and component args', function() {
15+
16+
// when
17+
const intersections = intersect(p1, p2);
18+
19+
// then
20+
expect(intersections).to.have.length(1);
21+
22+
// and then
23+
const [ intersection ] = intersections;
24+
25+
expect(intersection).to.have.keys([
26+
'segment1',
27+
'segment2',
28+
'x',
29+
'y',
30+
'bez1',
31+
'bez2',
32+
't1',
33+
't2'
34+
]);
35+
});
36+
37+
});
38+
39+
});

tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"module": "Node16",
5+
"moduleResolution": "Node16",
6+
"checkJs": true,
7+
"noImplicitAny": false
8+
},
9+
"include": [
10+
"test"
11+
]
12+
}

0 commit comments

Comments
 (0)