forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategoryPieChart.test.tsx
More file actions
43 lines (38 loc) · 1.35 KB
/
Copy pathCategoryPieChart.test.tsx
File metadata and controls
43 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
import { CategoryPieChart } from './CategoryPieChart';
import type { CategoryBreakdown } from '../../types/analytics';
vi.mock('../ThemeContext', () => ({
useTheme: () => ({
theme: 'light',
resolvedTheme: 'light',
setTheme: vi.fn(),
toggleTheme: vi.fn(),
}),
}));
vi.mock('recharts', async () => {
const actual = await vi.importActual('recharts');
return {
...actual,
ResponsiveContainer: ({ children }: { children: React.ReactNode }) => (
<div data-testid="responsive-container" style={{ width: 500, height: 300 }}>
{children}
</div>
),
};
});
const mockData: CategoryBreakdown[] = [
{ category: 'Food & Dining', amount: 890 },
{ category: 'Entertainment', amount: 420 },
{ category: 'Transport', amount: 310 },
];
describe('CategoryPieChart', () => {
it('renders the chart title', () => {
render(<CategoryPieChart data={mockData} />);
expect(screen.getByText('Category Breakdown')).toBeDefined();
});
it('has the correct id for export', () => {
const { container } = render(<CategoryPieChart data={mockData} />);
expect(container.querySelector('#category-pie-chart')).not.toBeNull();
});
});