test: tests unitaires Vitest — format, version-utils, rate-limit

- Installe vitest@4 + @vitest/coverage-v8 (40 tests, 0 échec)
- lib/__tests__/format.test.js        : 14 tests (formatKonstitisyon, formatDate, hasRestrictedChar)
- lib/__tests__/version-utils.test.js : 17 tests (filterVersions par texte/auteur/date, getFilterStats)
- lib/__tests__/rate-limit.test.js    : 9 tests avec fake timers (limite, reset, retryAfter, keys indépendantes)
- vitest.config.mjs : environnement node, imports explicites (pas de globals)
- package.json : scripts test / test:watch / test:coverage + override XO pour les fichiers de test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 06:30:10 +04:00
parent 170c3c5e90
commit 7b831d5bc4
7 changed files with 12342 additions and 3 deletions
+17 -2
View File
@@ -3,7 +3,10 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "xo"
"lint": "xo",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@directus/sdk": "^20.3.0",
@@ -28,7 +31,9 @@
"use-debounce": "^10.0.5"
},
"devDependencies": {
"@vitest/coverage-v8": "^4.1.4",
"eslint-config-xo-nextjs": "^6.0.0",
"vitest": "^4.1.4",
"xo": "^0.58.0"
},
"xo": {
@@ -49,6 +54,16 @@
"n/prefer-global/process": "off",
"comma-dangle": "off",
"unicorn/prevent-abbreviations": "off"
}
},
"overrides": [
{
"files": "lib/__tests__/**/*.js",
"envs": ["node", "es2020"],
"rules": {
"camelcase": ["error", {"properties": "never"}],
"capitalized-comments": "off"
}
}
]
}
}