Description
The useCopyToClipboard hook in hooks/copy-to-clipboard.ts handles clipboard writes and a 2-second "copied" feedback state, but has no tests.
Difficulty
Easy
Skills
Jest, React Testing Library (renderHook)
Relevant files
hooks/copy-to-clipboard.ts
hooks/__tests__/copy-to-clipboard.test.ts (create)
Tasks
Acceptance Criteria
- All tests pass with
npm test
- Clipboard API is mocked (no real clipboard access in CI)
- Use fake timers for the 2s reset behavior
Getting started
- Comment on this issue to get assigned
- Fork the repo and create a branch:
test/copy-to-clipboard
- Run
npm ci && npm test before opening a PR
Description
The
useCopyToClipboardhook inhooks/copy-to-clipboard.tshandles clipboard writes and a 2-second "copied" feedback state, but has no tests.Difficulty
Easy
Skills
Jest, React Testing Library (
renderHook)Relevant files
hooks/copy-to-clipboard.tshooks/__tests__/copy-to-clipboard.test.ts(create)Tasks
hooks/__tests__/copy-to-clipboard.test.tsnavigator.clipboard.writeTextcopied: true, then resets after timeoutfalseand does not setcopiedAcceptance Criteria
npm testGetting started
test/copy-to-clipboardnpm ci && npm testbefore opening a PR