Skip to content

Commit 126545b

Browse files
hungtcstbouffard
andauthored
feat: add test case based on jest (typed-mxgraph#22)
- move source to lib - add tests folder - update package-lock Co-authored-by: Thomas Bouffard <[email protected]>
1 parent 357ba95 commit 126545b

File tree

152 files changed

+5108
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+5108
-702
lines changed

.npmignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
tests/
3+
4+
.idea/
5+
.vscode/
6+
.github/
7+
8+
jest.config.ts
9+
tsconfig.spec.json

.prettierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"arrowParens": "always"
10+
}

.prettierrc.yaml

-8
This file was deleted.

index.d.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/// <reference path="./editor/index.d.ts" />
2-
/// <reference path="./handler/index.d.ts" />
3-
/// <reference path="./io/index.d.ts" />
4-
/// <reference path="./layout/index.d.ts" />
5-
/// <reference path="./model/index.d.ts" />
6-
/// <reference path="./util/index.d.ts" />
7-
/// <reference path="./shape/index.d.ts" />
8-
/// <reference path="./view/index.d.ts" />
9-
/// <reference path="./mxClient.d.ts" />
1+
/// <reference path="./lib/editor/index.d.ts" />
2+
/// <reference path="./lib/handler/index.d.ts" />
3+
/// <reference path="./lib/io/index.d.ts" />
4+
/// <reference path="./lib/layout/index.d.ts" />
5+
/// <reference path="./lib/model/index.d.ts" />
6+
/// <reference path="./lib/util/index.d.ts" />
7+
/// <reference path="./lib/shape/index.d.ts" />
8+
/// <reference path="./lib/view/index.d.ts" />
9+
/// <reference path="./lib/mxClient.d.ts" />
1010

1111
declare module 'mxgraph' {
1212
export interface mxGraphExportObject {

jest.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/en/configuration.html
4+
*/
5+
6+
export default {
7+
globals: {
8+
'ts-jest': {
9+
tsconfig: 'tsconfig.spec.json'
10+
}
11+
},
12+
preset: 'ts-jest',
13+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

io/README.md lib/io/README.md

io/index.d.ts lib/io/index.d.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mxClient.d.ts lib/mxClient.d.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

view/README.md lib/view/README.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package-lock.json

+5,026-681
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@
44
"author": "鸿则 <[email protected]>",
55
"license": "MIT",
66
"scripts": {
7-
"test": "tsc --noEmit",
7+
"pretest": "tsc --noEmit",
8+
"test": "jest",
89
"eslint": "eslint \"**/*.d.ts\"",
910
"prettier": "prettier --write \"**/*.d.ts\"",
1011
"prettier:check": "prettier --check \"**/*.d.ts\""
1112
},
1213
"devDependencies": {
14+
"@types/jest": "^26.0.19",
1315
"@typescript-eslint/eslint-plugin": "^3.10.1",
1416
"@typescript-eslint/parser": "^3.10.1",
1517
"eslint": "^7.11.0",
18+
"jest": "^26.6.3",
19+
"mxgraph": "^4.2.2",
1620
"prettier": "^2.1.2",
17-
"typescript": "^3.9.3"
21+
"ts-jest": "^26.4.4",
22+
"ts-node": "^9.1.1",
23+
"typescript": "^4.1.3"
1824
},
1925
"peerDependencies": {
20-
"mxgraph": "^4.2.0"
26+
"mxgraph": "^4.2.2"
2127
},
2228
"description": "mxGraph typescript declarations",
2329
"main": "index.d.ts",

tests/factory.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="../index.d.ts" />
2+
import factory, { mxGraphExportObject } from 'mxgraph';
3+
4+
describe('factory', () => {
5+
let mx: mxGraphExportObject;
6+
7+
beforeAll(() => {
8+
mx = factory();
9+
});
10+
11+
it('should be created', () => {
12+
expect(mx).toBeDefined();
13+
});
14+
15+
it('version should be string', () => {
16+
expect(typeof(mx.mxClient.VERSION)).toEqual('string');
17+
});
18+
19+
});

tsconfig.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": "./",
34
"target": "es5",
45
"module": "commonjs",
56
"strict": true,
7+
"skipLibCheck": true,
68
"esModuleInterop": true,
79
"forceConsistentCasingInFileNames": true
8-
}
10+
},
11+
"include": [
12+
"lib/**/*.d.ts"
13+
]
914
}

tsconfig.spec.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": [
4+
"**/*.d.ts",
5+
"tests/**/*.spec.ts"
6+
]
7+
}

0 commit comments

Comments
 (0)