82 tests covering download.ts and all React Query hooks. API modules are mocked with vi.mock; mutation tests spy on queryClient.invalidateQueries to verify cache invalidation. Conditional queries (null id) are verified to stay idle. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
1.2 KiB
Markdown
28 lines
1.2 KiB
Markdown
---
|
|
# nuzlocke-tracker-ee9s
|
|
title: Unit tests for frontend utilities and hooks
|
|
status: completed
|
|
type: task
|
|
priority: normal
|
|
created_at: 2026-02-10T09:33:38Z
|
|
updated_at: 2026-02-21T12:47:19Z
|
|
parent: nuzlocke-tracker-yzpb
|
|
---
|
|
|
|
Write unit tests for the frontend utility functions and custom React hooks.
|
|
|
|
All API modules are mocked with `vi.mock`. Hooks are tested with `renderHook` from @testing-library/react, wrapped in `QueryClientProvider`. Mutation tests spy on `queryClient.invalidateQueries` to verify cache invalidation.
|
|
|
|
## Checklist
|
|
|
|
- [x] Test `utils/formatEvolution.ts` — done in smoke test
|
|
- [x] Test `utils/download.ts` — blob URL creation, filename, cleanup
|
|
- [x] Test `hooks/useGames.ts` — query hooks and disabled state
|
|
- [x] Test `hooks/useRuns.ts` — query hooks + mutations with cache invalidation
|
|
- [x] Test `hooks/useEncounters.ts` — mutations and conditional queries
|
|
- [x] Test `hooks/usePokemon.ts` — conditional queries
|
|
- [x] Test `hooks/useGenlockes.ts` — queries and mutations
|
|
- [x] Test `hooks/useBosses.ts` — queries and mutations
|
|
- [x] Test `hooks/useStats.ts` — single query hook
|
|
- [x] Test `hooks/useAdmin.ts` — representative subset (usePokemonList, useCreateGame, useDeleteGame)
|