Skip to content

test(ui): add unit test coverage for Button variant, size, and className (#421) - #425

Open
PINYOPATTANAWASANPORN wants to merge 1 commit into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:test/button-variant-size-coverage-421
Open

PINYOPATTANAWASANPORN wants to merge 1 commit into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:test/button-variant-size-coverage-421

Conversation

@PINYOPATTANAWASANPORN

Copy link
Copy Markdown

Summary of Changes

  • Expand src/components/ui/Button.test.tsx to provide comprehensive unit test coverage for the component's core props: variant and size, as well as className composition.
  • Add test suite for variant prop: validates default primary styling, as well as secondary, ghost, and outline class mappings.
  • Add test suite for size prop: validates default md sizing, as well as sm and lg padding and typography class mappings.
  • Add test suite for custom className merging: validates proper composition with Tailwind classes using cn().

Root Cause / Technical Context

  • Button.test.tsx previously only verified the loading prop (aria-busy, spinner presence, and force-disabled state).
  • The variant and size props constitute the fundamental visual contract of Button, used across all platform buttons (bounty funding, claiming, submission, filters). Without test coverage, regressions in variant styling or size classes could pass unnoticed in CI.

Verification & Testing

  • Unit tests added to src/components/ui/Button.test.tsx:
    • Button — variant prop:
      • defaults to primary variant styling: asserts bg-slate-900 text-white.
      • applies secondary variant styling: asserts bg-indigo-50 text-indigo-700.
      • applies ghost variant styling: asserts bg-transparent text-slate-600.
      • applies outline variant styling: asserts border border-slate-200 text-slate-800.
    • Button — size prop:
      • defaults to md size styling: asserts px-4 py-2 text-sm.
      • applies sm size styling: asserts px-3 py-1.5 text-sm.
      • applies lg size styling: asserts px-6 py-3 text-base.
    • Button — className composition:
      • merges custom className with base, variant, and size classes.

Closes #421

…ame (MergeFi#421)

- Test default and explicit variant styles (primary, secondary, ghost, outline)
- Test default and explicit size classes (sm, md, lg)
- Test custom className merging and composition with Tailwind utility classes
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

@PINYOPATTANAWASANPORN is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button.test.tsx only covers the loading prop — variant and size, the component's core API, have zero test coverage

1 participant