Skip to content

Commit dcaafea

Browse files
authored
test(copyrepobutton): add theme contrast coverage (JhaSourav07#3028)
## Description Fixes JhaSourav07#2805 Added theme contrast test coverage for `app/components/CopyRepoButton.tsx`. ### Tests Added * Verifies light mode background and border contrast classes. * Verifies dark mode background and border contrast classes. * Ensures readable font weight is preserved. * Confirms icon and text spacing classes prevent overlap. * Verifies transition and hover classes do not remove contrast styling. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Test-only changes) ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally. * [ ] I have run `npm run format` and `npm run lint` locally and resolved all errors. * [x] My commits follow the Conventional Commits format. * [ ] I have updated `README.md` if I added a new theme or URL parameter. (Not applicable) * [x] I have starred the repo. * [x] I have made sure that I have only one commit to merge in this PR. * [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard. (Not applicable) * [ ] (Recommended) I joined the CommitPulse Discord community.
2 parents 9ac8926 + cdf779c commit dcaafea

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)