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> <pre>
- tailwindcss postcss autoprefixer - tailwindcss postcss autoprefixer
- eslint-plugin-simple-import-sort - eslint-plugin-simple-import-sort
- jest
- ts-jest
- @types/jest
</pre> </pre>
</details> </details>
<details> <details>

View File

@ -5,4 +5,8 @@ $pyExec = "$PSScriptRoot\backend\venv\Scripts\python.exe"
$djangoSrc = "$PSScriptRoot\backend\manage.py" $djangoSrc = "$PSScriptRoot\backend\manage.py"
& $pyExec $djangoSrc check & $pyExec $djangoSrc check
& $pyExec $djangoSrc test & $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", "version": "0.1.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"test": "jest",
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
@ -26,6 +27,7 @@
"reagraph": "^4.11.1" "reagraph": "^4.11.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5", "@types/node": "^20.4.5",
"@types/react": "^18.2.15", "@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
@ -37,9 +39,21 @@
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3", "eslint-plugin-react-refresh": "^0.4.3",
"eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-simple-import-sort": "^10.0.0",
"jest": "^29.6.2",
"postcss": "^8.4.27", "postcss": "^8.4.27",
"tailwindcss": "^3.3.3", "tailwindcss": "^3.3.3",
"ts-jest": "^29.1.1",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5" "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"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true,
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",