test: move test files, add ts configs

This commit is contained in:
2026-07-13 08:15:53 +05:00
parent c8c9ed5f39
commit 72f272246f
7 changed files with 58 additions and 44 deletions
+12 -13
View File
@@ -14,17 +14,15 @@ src/
├── ports.ts # Интерфейсы: IFileSystem, ITaskRepository, IConfigProvider ├── ports.ts # Интерфейсы: IFileSystem, ITaskRepository, IConfigProvider
├── storage/ ├── storage/
│ ├── FsTaskRepository.ts # ITaskRepository → зависит только от IFileSystem, markdown, uuid │ ├── FsTaskRepository.ts # ITaskRepository → зависит только от IFileSystem, markdown, uuid
│ ├── FsTaskRepository.test.ts # unit (sociable) — colocation с модулем
│ ├── VscodeConfigProvider.ts # IConfigProvider → зависит от vscode │ ├── VscodeConfigProvider.ts # IConfigProvider → зависит от vscode
│ └── NodeFileSystem.ts # IFileSystem → обёртка над fs.promises │ └── NodeFileSystem.ts # IFileSystem → обёртка над fs.promises
├── utils/
│ └── markdown.test.ts # unit — colocation
tests/ tests/
── utils/ ── helpers/
── markdown.test.ts ── InMemoryFileSystem.ts # shared fakes; integration/e2e — сюда же позже
│ └── uuid.test.ts
├── storage/
│ ├── FsTaskRepository.test.ts
│ └── helpers/
│ └── InMemoryFileSystem.ts
``` ```
### Удалить ### Удалить
@@ -46,12 +44,13 @@ tests/
## Тесты ## Тесты
| Тест | I/O | Что проверяет | | Тест | Где | I/O | Что проверяет |
| ------------------ | ------------------------ | -------------------------------------------- | | ---------------- | ----------------------- | ------------------------ | -------------------------------------------- |
| FsTaskRepository | InMemoryFileSystem (Map) | CRUD, фильтрация по extension, контент файла | | FsTaskRepository | `src/storage/*.test.ts` | InMemoryFileSystem (Map) | CRUD, фильтрация по extension, контент файла |
| markdown | — | parse, serialize, round-trip, default-ы | | markdown | `src/utils/*.test.ts` | — | parse, serialize, round-trip, default-ы |
| uuid | — | валидный формат, уникальность |
| InMemoryFileSystem | — | read/write/readdir/mkdir | Unit/sociable unit — рядом с модулем (`src/**/*.test.ts`).
Shared fakes и будущие integration/e2e — в `tests/`.
## Что НЕ тестируем (пока) ## Что НЕ тестируем (пока)
+3 -1
View File
@@ -91,7 +91,9 @@
"build": "vite build", "build": "vite build",
"watch": "vite build --watch", "watch": "vite build --watch",
"vscode:prepublish": "npm run build", "vscode:prepublish": "npm run build",
"lint": "tsc --noEmit", "lint": "npm run lint:app && npm run lint:test",
"lint:app": "tsc --noEmit -p tsconfig.app.json",
"lint:test": "tsc --noEmit -p tsconfig.test.json",
"format": "prettier --write .", "format": "prettier --write .",
"test": "vitest", "test": "vitest",
"test:run": "vitest run" "test:run": "vitest run"
@@ -1,8 +1,8 @@
import { describe, it, expect, beforeEach } from "vitest";
import { FsTaskRepository } from "@/storage/FsTaskRepository";
import { InMemoryFileSystem } from "../helpers/InMemoryFileSystem";
import { ITaskRepository } from "@/ports";
import { Task } from "@/model/task"; import { Task } from "@/model/task";
import { ITaskRepository } from "@/ports";
import { beforeEach, describe, expect, it } from "vitest";
import { InMemoryFileSystem } from "../../tests/helpers/InMemoryFileSystem";
import { FsTaskRepository } from "./FsTaskRepository";
describe("FsTaskRepository", () => { describe("FsTaskRepository", () => {
let fs: InMemoryFileSystem; let fs: InMemoryFileSystem;
+1 -6
View File
@@ -1,8 +1,3 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.test.json"
"include": ["**/*", "../src/**/*"],
"compilerOptions": {
"noEmit": true,
"rootDir": ".."
}
} }
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2022",
"outDir": "out",
"rootDir": "src",
"lib": ["ES2022"],
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"types": ["node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "out", ".vscode-test", "src/**/*.test.ts"]
}
+5 -20
View File
@@ -1,22 +1,7 @@
{ {
"compilerOptions": { "files": [],
"module": "commonjs", "references": [
"target": "ES2022", { "path": "./tsconfig.app.json" },
"outDir": "out", { "path": "./tsconfig.test.json" }
"rootDir": "src", ]
"lib": ["ES2022"],
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"types": ["node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "out", ".vscode-test"]
} }
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
"declaration": false,
"types": ["node"]
},
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "out", ".vscode-test"]
}