Add testing for TS modules

This commit is contained in:
IRBorisov 2023-08-01 23:43:43 +03:00
parent c7d4902137
commit 6bb034ae51
6 changed files with 3658 additions and 13 deletions

View File

@ -33,6 +33,9 @@ This readme file is used mostly to document project dependencies
<pre>
- tailwindcss postcss autoprefixer
- eslint-plugin-simple-import-sort
- jest
- ts-jest
- @types/jest
</pre>
</details>
<details>

View File

@ -6,3 +6,7 @@ $djangoSrc = "$PSScriptRoot\backend\manage.py"
& $pyExec $djangoSrc check
& $pyExec $djangoSrc test
Set-Location $PSScriptRoot\frontend
& npm test

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
"version": "0.1.0",
"type": "module",
"scripts": {
"test": "jest",
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
@ -26,6 +27,7 @@
"reagraph": "^4.11.1"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
@ -37,9 +39,21 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
"jest": "^29.6.2",
"postcss": "^8.4.27",
"tailwindcss": "^3.3.3",
"ts-jest": "^29.1.1",
"typescript": "^5.0.2",
"vite": "^4.4.5"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"transform": {
"node_modules/variables/.+\\.(j|t)sx?$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!variables/.*)"
]
}
}

View File

@ -0,0 +1,17 @@
import { Graph } from './Graph';
describe('Testing Graph constuction', () => {
test('empty Graph should be empty', () => {
const graph = new Graph();
expect(graph.nodes.size).toBe(0);
});
test('adding edges should create nodes', () => {
const graph = new Graph();
graph.addEdge(13, 37);
expect([... graph.nodes.keys()]).toStrictEqual([13, 37]);
graph.addEdge(13, 38);
expect([... graph.nodes.keys()]).toStrictEqual([13, 37, 38]);
});
});

View File

@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
/* Bundler mode */
"moduleResolution": "bundler",