Logo
Explore Help
Register Sign In
admin/cc-switch
1
0
Fork 0
You've already forked cc-switch
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
Files
c2031c9b5c5a5ed6205ca61d2470f5ecdc7cd126
cc-switch/tests/setupTests.ts

24 lines
502 B
TypeScript
Raw Normal View History

test: add frontend testing infrastructure with vitest - Introduce Vitest + React Testing Library + jsdom environment - Add useDragSort hook unit tests covering: * Sorting logic (sortIndex → createdAt → name) * Successful drag operation (API call + cache invalidation) * Failed drag operation (error toast display) * Edge case (no valid target, no API call) - Configure global test setup (i18n mock, auto cleanup) - Update TypeScript configs to include tests/ directory - Add test development plan documentation Test Coverage: ✓ Provider drag-and-drop sorting core logic ✓ React Query cache refresh ✓ Toast notification display ✓ Boundary condition handling Test Results: 4/4 passed (671ms) Next Steps: Sprint 2 - component tests with MSW mock layer
2025-10-25 10:08:06 +08:00
import "@testing-library/jest-dom";
import { afterEach, beforeAll } from "vitest";
import { cleanup } from "@testing-library/react";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
beforeAll(async () => {
await i18n.use(initReactI18next).init({
lng: "zh",
fallbackLng: "zh",
resources: {
zh: { translation: {} },
en: { translation: {} },
},
interpolation: {
escapeValue: false,
},
});
});
afterEach(() => {
cleanup();
});
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.2 Page: 192ms Template: 20ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API