test: move test files, add ts configs
This commit is contained in:
+12
-13
@@ -14,17 +14,15 @@ src/
|
||||
├── ports.ts # Интерфейсы: IFileSystem, ITaskRepository, IConfigProvider
|
||||
├── storage/
|
||||
│ ├── FsTaskRepository.ts # ITaskRepository → зависит только от IFileSystem, markdown, uuid
|
||||
│ ├── FsTaskRepository.test.ts # unit (sociable) — colocation с модулем
|
||||
│ ├── VscodeConfigProvider.ts # IConfigProvider → зависит от vscode
|
||||
│ └── NodeFileSystem.ts # IFileSystem → обёртка над fs.promises
|
||||
├── utils/
|
||||
│ └── markdown.test.ts # unit — colocation
|
||||
|
||||
tests/
|
||||
├── utils/
|
||||
│ ├── markdown.test.ts
|
||||
│ └── uuid.test.ts
|
||||
├── storage/
|
||||
│ ├── FsTaskRepository.test.ts
|
||||
│ └── helpers/
|
||||
│ └── InMemoryFileSystem.ts
|
||||
└── helpers/
|
||||
└── InMemoryFileSystem.ts # shared fakes; integration/e2e — сюда же позже
|
||||
```
|
||||
|
||||
### Удалить
|
||||
@@ -46,12 +44,13 @@ tests/
|
||||
|
||||
## Тесты
|
||||
|
||||
| Тест | I/O | Что проверяет |
|
||||
| ------------------ | ------------------------ | -------------------------------------------- |
|
||||
| FsTaskRepository | InMemoryFileSystem (Map) | CRUD, фильтрация по extension, контент файла |
|
||||
| markdown | — | parse, serialize, round-trip, default-ы |
|
||||
| uuid | — | валидный формат, уникальность |
|
||||
| InMemoryFileSystem | — | read/write/readdir/mkdir |
|
||||
| Тест | Где | I/O | Что проверяет |
|
||||
| ---------------- | ----------------------- | ------------------------ | -------------------------------------------- |
|
||||
| FsTaskRepository | `src/storage/*.test.ts` | InMemoryFileSystem (Map) | CRUD, фильтрация по extension, контент файла |
|
||||
| markdown | `src/utils/*.test.ts` | — | parse, serialize, round-trip, default-ы |
|
||||
|
||||
Unit/sociable unit — рядом с модулем (`src/**/*.test.ts`).
|
||||
Shared fakes и будущие integration/e2e — в `tests/`.
|
||||
|
||||
## Что НЕ тестируем (пока)
|
||||
|
||||
|
||||
+3
-1
@@ -91,7 +91,9 @@
|
||||
"build": "vite build",
|
||||
"watch": "vite build --watch",
|
||||
"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 .",
|
||||
"test": "vitest",
|
||||
"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 { ITaskRepository } from "@/ports";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { InMemoryFileSystem } from "../../tests/helpers/InMemoryFileSystem";
|
||||
import { FsTaskRepository } from "./FsTaskRepository";
|
||||
|
||||
describe("FsTaskRepository", () => {
|
||||
let fs: InMemoryFileSystem;
|
||||
+1
-6
@@ -1,8 +1,3 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["**/*", "../src/**/*"],
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"rootDir": ".."
|
||||
}
|
||||
"extends": "../tsconfig.test.json"
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,22 +1,7 @@
|
||||
{
|
||||
"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"]
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.test.json" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
Reference in New Issue
Block a user