Skip to content

Commit 38c6ea4

Browse files
test(dashboard): add stats card skeleton tests (JhaSourav07#827)
* test(dashboard): add stats card skeleton tests * fix(test): resolve stats skeleton CI issues
1 parent 53afb80 commit 38c6ea4

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { render } from '@testing-library/react';
3+
4+
import StatsCardSkeleton from './StatsCardSkeleton';
5+
6+
describe('StatsCardSkeleton', () => {
7+
it('renders without crashing', () => {
8+
const { container } = render(<StatsCardSkeleton />);
9+
10+
expect(container).toBeDefined();
11+
});
12+
13+
it('renders exactly 12 chart bar elements', () => {
14+
const { container } = render(<StatsCardSkeleton />);
15+
16+
const bars = container.querySelectorAll('.rounded-t-\\[1px\\]');
17+
18+
expect(bars.length).toBe(12);
19+
});
20+
21+
it('renders shimmer class on all chart bars', () => {
22+
const { container } = render(<StatsCardSkeleton />);
23+
24+
const bars = container.querySelectorAll('.rounded-t-\\[1px\\]');
25+
26+
bars.forEach((bar) => {
27+
expect(bar.className).toContain('shimmer');
28+
});
29+
});
30+
31+
it('matches snapshot without random variation', () => {
32+
const { container } = render(<StatsCardSkeleton />);
33+
34+
expect(container.firstChild).toMatchSnapshot();
35+
});
36+
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`StatsCardSkeleton > matches snapshot without random variation 1`] = `
4+
<div
5+
class="p-6 rounded-xl bg-[#0a0a0a] border border-[rgba(255,255,255,0.08)] overflow-hidden"
6+
>
7+
<div
8+
class="flex justify-between items-start mb-6"
9+
>
10+
<div
11+
class="space-y-3"
12+
>
13+
<div
14+
class="h-3 w-24 shimmer rounded"
15+
/>
16+
<div
17+
class="h-8 w-32 shimmer rounded"
18+
/>
19+
<div
20+
class="h-3 w-36 shimmer rounded"
21+
/>
22+
</div>
23+
<div
24+
class="h-9 w-9 rounded-lg shimmer"
25+
/>
26+
</div>
27+
<div
28+
class="w-full h-8 flex items-end justify-between gap-px opacity-30"
29+
>
30+
<div
31+
class="flex-1 shimmer rounded-t-[1px]"
32+
style="height: 24%;"
33+
/>
34+
<div
35+
class="flex-1 shimmer rounded-t-[1px]"
36+
style="height: 32%;"
37+
/>
38+
<div
39+
class="flex-1 shimmer rounded-t-[1px]"
40+
style="height: 18%;"
41+
/>
42+
<div
43+
class="flex-1 shimmer rounded-t-[1px]"
44+
style="height: 45%;"
45+
/>
46+
<div
47+
class="flex-1 shimmer rounded-t-[1px]"
48+
style="height: 38%;"
49+
/>
50+
<div
51+
class="flex-1 shimmer rounded-t-[1px]"
52+
style="height: 52%;"
53+
/>
54+
<div
55+
class="flex-1 shimmer rounded-t-[1px]"
56+
style="height: 28%;"
57+
/>
58+
<div
59+
class="flex-1 shimmer rounded-t-[1px]"
60+
style="height: 42%;"
61+
/>
62+
<div
63+
class="flex-1 shimmer rounded-t-[1px]"
64+
style="height: 35%;"
65+
/>
66+
<div
67+
class="flex-1 shimmer rounded-t-[1px]"
68+
style="height: 48%;"
69+
/>
70+
<div
71+
class="flex-1 shimmer rounded-t-[1px]"
72+
style="height: 30%;"
73+
/>
74+
<div
75+
class="flex-1 shimmer rounded-t-[1px]"
76+
style="height: 22%;"
77+
/>
78+
</div>
79+
</div>
80+
`;

0 commit comments

Comments
 (0)