Skip to content

Commit f8e87bb

Browse files
test(leaderboard): add theme contrast coverage
1 parent e3369ea commit f8e87bb

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { render } from '@testing-library/react';
2+
import { describe, expect, it, vi } from 'vitest';
3+
import type { HTMLAttributes, ReactNode } from 'react';
4+
5+
import Leaderboard from './Leaderboard';
6+
7+
vi.mock('next/image', () => ({
8+
default: () => null,
9+
}));
10+
11+
vi.mock('framer-motion', () => ({
12+
motion: {
13+
div: ({
14+
children,
15+
...props
16+
}: HTMLAttributes<HTMLDivElement> & {
17+
children?: ReactNode;
18+
}) => <div {...props}>{children}</div>,
19+
},
20+
}));
21+
22+
describe('Leaderboard theme contrast behavior', () => {
23+
const contributors = [
24+
{
25+
id: 1,
26+
login: 'alice',
27+
avatar_url: 'https://example.com/alice.png',
28+
contributions: 100,
29+
html_url: 'https://github.com/alice',
30+
},
31+
{
32+
id: 2,
33+
login: 'bob',
34+
avatar_url: 'https://example.com/bob.png',
35+
contributions: 90,
36+
html_url: 'https://github.com/bob',
37+
},
38+
{
39+
id: 3,
40+
login: 'charlie',
41+
avatar_url: 'https://example.com/charlie.png',
42+
contributions: 80,
43+
html_url: 'https://github.com/charlie',
44+
},
45+
{
46+
id: 4,
47+
login: 'david',
48+
avatar_url: 'https://example.com/david.png',
49+
contributions: 70,
50+
html_url: 'https://github.com/david',
51+
},
52+
];
53+
54+
it('renders leaderboard container', () => {
55+
const { container } = render(<Leaderboard contributors={contributors} />);
56+
57+
expect(container.firstChild).toBeTruthy();
58+
});
59+
60+
it('includes dark mode background classes', () => {
61+
const { container } = render(<Leaderboard contributors={contributors} />);
62+
63+
expect(container.innerHTML).toContain('dark:bg');
64+
});
65+
66+
it('includes dark mode text classes', () => {
67+
const { container } = render(<Leaderboard contributors={contributors} />);
68+
69+
expect(container.innerHTML).toContain('dark:text-white');
70+
});
71+
72+
it('includes dark mode border classes', () => {
73+
const { container } = render(<Leaderboard contributors={contributors} />);
74+
75+
expect(container.innerHTML).toContain('dark:border');
76+
});
77+
78+
it('includes hover contrast styling for both themes', () => {
79+
const { container } = render(<Leaderboard contributors={contributors} />);
80+
81+
expect(container.innerHTML).toContain('dark:hover');
82+
});
83+
});

0 commit comments

Comments
 (0)