|
| 1 | +import { render, screen } from '@testing-library/react'; |
| 2 | +import { describe, expect, it, vi } from 'vitest'; |
| 3 | + |
| 4 | +import CopyRepoButton from './CopyRepoButton'; |
| 5 | + |
| 6 | +vi.mock('lucide-react', () => ({ |
| 7 | + Copy: () => <svg data-testid="copy-icon" />, |
| 8 | +})); |
| 9 | + |
| 10 | +describe('CopyRepoButton theme contrast behavior', () => { |
| 11 | + it('includes light mode background and border contrast classes', () => { |
| 12 | + render(<CopyRepoButton />); |
| 13 | + |
| 14 | + const button = screen.getByRole('button', { name: /copy url/i }); |
| 15 | + |
| 16 | + expect(button.className).toContain('bg-white/60'); |
| 17 | + expect(button.className).toContain('border-black/10'); |
| 18 | + }); |
| 19 | + |
| 20 | + it('includes dark mode background and border contrast classes', () => { |
| 21 | + render(<CopyRepoButton />); |
| 22 | + |
| 23 | + const button = screen.getByRole('button', { name: /copy url/i }); |
| 24 | + |
| 25 | + expect(button.className).toContain('dark:bg-white/5'); |
| 26 | + expect(button.className).toContain('dark:border-white/10'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('keeps readable font weight for button text', () => { |
| 30 | + render(<CopyRepoButton />); |
| 31 | + |
| 32 | + expect(screen.getByRole('button').className).toContain('font-semibold'); |
| 33 | + }); |
| 34 | + |
| 35 | + it('preserves spacing classes so icon and text do not overlap', () => { |
| 36 | + render(<CopyRepoButton />); |
| 37 | + |
| 38 | + const button = screen.getByRole('button'); |
| 39 | + |
| 40 | + expect(button.className).toContain('inline-flex'); |
| 41 | + expect(button.className).toContain('items-center'); |
| 42 | + expect(button.className).toContain('gap-2'); |
| 43 | + }); |
| 44 | + |
| 45 | + it('keeps transition and hover classes without removing contrast styling', () => { |
| 46 | + render(<CopyRepoButton />); |
| 47 | + |
| 48 | + const button = screen.getByRole('button'); |
| 49 | + |
| 50 | + expect(button.className).toContain('transition-all'); |
| 51 | + expect(button.className).toContain('hover:scale-105'); |
| 52 | + expect(button.className).toContain('bg-white/60'); |
| 53 | + expect(button.className).toContain('dark:bg-white/5'); |
| 54 | + }); |
| 55 | +}); |
0 commit comments