Files
goodgo-platform/apps/web/components/khu-cong-nghiep/__tests__/park-compare-client.spec.tsx
Ho Ngoc Hai 7d26436461 test(web): add component tests for 10 untested frontend components (GOO-54)
Cover critical-path and feature components that were missing tests:
- charts: district-heatmap
- chuyen-nhuong: detail-client, transfer-wizard-client
- du-an: detail-client, project-ai-advice-card, project-map
- khu-cong-nghiep: detail-client, listing-search-client, park-compare-client, park-map

All 49 new tests pass with Vitest + React Testing Library.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-23 20:29:19 +07:00

48 lines
1.6 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
vi.mock('recharts', () => ({
Radar: () => null,
RadarChart: ({ children }: { children: React.ReactNode }) => <div data-testid="radar-chart">{children}</div>,
PolarGrid: () => null,
PolarAngleAxis: () => null,
PolarRadiusAxis: () => null,
ResponsiveContainer: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
Legend: () => null,
Tooltip: () => null,
}));
vi.mock('@/i18n/navigation', () => ({
Link: ({ children, ...props }: React.PropsWithChildren<Record<string, unknown>>) => <a {...props}>{children}</a>,
}));
vi.mock('@/lib/hooks/use-khu-cong-nghiep', () => ({
useIndustrialCompare: () => ({ data: undefined, isLoading: false }),
useIndustrialParksSearch: () => ({ data: { data: [] } }),
}));
vi.mock('@/lib/khu-cong-nghiep-api', () => ({
PARK_STATUS_COLORS: { OPERATIONAL: 'bg-green-100 text-green-800' },
PARK_STATUS_LABELS: { OPERATIONAL: 'Hoạt động' },
REGION_LABELS: { SOUTH: 'Miền Nam' },
}));
import { ParkCompareClient } from '../park-compare-client';
describe('ParkCompareClient', () => {
it('renders heading', () => {
render(<ParkCompareClient />);
expect(screen.getByText('So Sánh Khu Công Nghiệp')).toBeInTheDocument();
});
it('shows empty state when fewer than 2 parks selected', () => {
render(<ParkCompareClient />);
expect(screen.getByText('Chọn ít nhất 2 KCN để so sánh')).toBeInTheDocument();
});
it('renders add park button', () => {
render(<ParkCompareClient />);
expect(screen.getByText('Thêm KCN')).toBeInTheDocument();
});
});