2026-02-10 10:34:45 +01:00
---
# nuzlocke-tracker-ee9s
title: Unit tests for frontend utilities and hooks
2026-02-21 13:47:55 +01:00
status: completed
2026-02-10 10:34:45 +01:00
type: task
2026-02-21 13:47:55 +01:00
priority: normal
2026-02-10 10:34:45 +01:00
created_at: 2026-02-10T09:33:38Z
2026-02-21 13:47:55 +01:00
updated_at: 2026-02-21T12:47:19Z
2026-02-10 10:34:45 +01:00
parent: nuzlocke-tracker-yzpb
---
Write unit tests for the frontend utility functions and custom React hooks.
2026-02-21 13:47:55 +01:00
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.
2026-02-10 10:34:45 +01:00
2026-02-21 13:47:55 +01:00
## Checklist
2026-02-10 10:34:45 +01:00
2026-02-21 13:47:55 +01:00
- [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)