Skip to content

test: Add unit tests for useClipboardCopy custom hook #236

Description

@O2sa

Add unit test coverage for the useClipboardCopy React hook located in src/hooks/use-clipboard-copy.ts.

Motivation

useClipboardCopy is used across user profiles and comparison views. Having automated tests guarantees that clipboard API timeouts and error fallbacks remain stable.

Tasks

  • Create src/hooks/tests/use-clipboard-copy.test.ts using Vitest.
  • Mock navigator.clipboard.writeText.
  • Test successful text copying and verify copied state becomes true.
  • Test timeout behavior using vi.useFakeTimers() to ensure copied resets to false after timeoutMs.
  • Test clipboard rejection/failure to ensure graceful error handling (copied remains false).
  • Run pnpm test.

Tip

🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨

Activity

  1. CodeByPeace commented on Oct 11, 2026

    @CodeByPeace
    Contributor

    assign me

    I would like to take this one. I will write the tests with Vitest and run pnpm test before I open the PR.

  2. github-actions commented on Oct 11, 2026

    @github-actions

    🎉 Issue assigned to @CodeByPeace! Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions