Skip to content

Commit 89f8983

Browse files
test(DashboardPage): verify Heatmap receives the activity data prop
1 parent df724d4 commit 89f8983

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

app/(root)/dashboard/[username]/page.test.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ vi.mock('@/components/dashboard/CommitClock', () => ({
4646
}));
4747

4848
vi.mock('@/components/dashboard/Heatmap', () => ({
49-
default: () => <div data-testid="heatmap">Heatmap</div>,
49+
default: ({ data }: { data: unknown[] }) => (
50+
<div data-testid="heatmap" data-prop={JSON.stringify(data)}>
51+
Heatmap
52+
</div>
53+
),
5054
}));
5155

5256
vi.mock('@/components/dashboard/AIInsights', () => ({
@@ -137,4 +141,15 @@ describe('DashboardPage', () => {
137141
expect(screen.getByText('Contributions: 500')).toBeDefined();
138142
});
139143
});
144+
it('passes the correct activity data to Heatmap', async () => {
145+
const PageContent = await DashboardPage({
146+
params: Promise.resolve({ username: 'octocat' }),
147+
searchParams: Promise.resolve({}),
148+
});
149+
150+
render(PageContent);
151+
152+
const heatmap = screen.getByTestId('heatmap');
153+
expect(JSON.parse(heatmap.getAttribute('data-prop') ?? '[]')).toEqual(mockData.activity);
154+
});
140155
});

0 commit comments

Comments
 (0)