Skip to content

Commit 1272159

Browse files
authored
test(Icons-theme-contrast): verify Dark and Light Prefers-Color-Scheme Visual Cohesion (Variation 3) (JhaSourav07#3113)
## Description This PR implements testing to verify Dark and Light `prefers-color-scheme` visual cohesion for the `Icons` component. It ensures that standard icons dynamically adapt to the application's theme using `currentColor`, while validating that the `CheckIcon` strictly retains its semantic green success color (`#10b981`) across both dark and light themes. Fixes JhaSourav07#2815 ## 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 addition only, no visual changes). ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 3880d1e + a09137d commit 1272159

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { render } from '@testing-library/react';
2+
import { describe, expect, it } from 'vitest';
3+
4+
import { BoxIcon, CheckIcon, CloseIcon, CopyIcon, ZapIcon } from './Icons';
5+
6+
describe('Icons theme contrast behavior', () => {
7+
it('renders CheckIcon with fixed semantic color for success state', () => {
8+
const { container } = render(<CheckIcon />);
9+
const svg = container.querySelector('svg');
10+
// Verifies the icon maintains visual cohesion by using a fixed color
11+
// that works well in both light and dark modes
12+
expect(svg?.getAttribute('stroke')).toBe('#10b981');
13+
});
14+
15+
it('renders CopyIcon with inherited color for theme adaptability', () => {
16+
const { container } = render(<CopyIcon />);
17+
const svg = container.querySelector('svg');
18+
// Verifies the icon uses currentColor to adapt to parent theme context
19+
expect(svg?.getAttribute('stroke')).toBe('currentColor');
20+
});
21+
22+
it('renders ZapIcon with inherited color for theme adaptability', () => {
23+
const { container } = render(<ZapIcon />);
24+
const svg = container.querySelector('svg');
25+
expect(svg?.getAttribute('stroke')).toBe('currentColor');
26+
});
27+
28+
it('renders BoxIcon with inherited color for theme adaptability', () => {
29+
const { container } = render(<BoxIcon />);
30+
const svg = container.querySelector('svg');
31+
expect(svg?.getAttribute('stroke')).toBe('currentColor');
32+
});
33+
34+
it('renders CloseIcon with inherited color for theme adaptability', () => {
35+
const { container } = render(<CloseIcon />);
36+
const svg = container.querySelector('svg');
37+
expect(svg?.getAttribute('stroke')).toBe('currentColor');
38+
});
39+
});

0 commit comments

Comments
 (0)