Files
goodgo-platform/apps/web/components/ui/__tests__/card.spec.tsx
Ho Ngoc Hai ccb82fddf8 feat(cache): implement Redis caching for search & analytics hot paths
- Add TTL-specific cache durations: district stats (5min), market report (15min), heatmap (5min)
- Add Redis caching to GeoSearch handler with 60s TTL
- Add cache invalidation on listing.approved, listing.updated, listing.deactivated, listing.sold events
- Invalidate search, geo_search, and all analytics cache prefixes on listing state changes
- Update tests for new CacheService dependency in event handler and geo-search handler

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 22:51:16 +07:00

41 lines
1.5 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '../card';
describe('Card', () => {
it('renders card with all sub-components', () => {
render(
<Card data-testid="card">
<CardHeader>
<CardTitle>Title</CardTitle>
<CardDescription>Description</CardDescription>
</CardHeader>
<CardContent>Content</CardContent>
<CardFooter>Footer</CardFooter>
</Card>,
);
expect(screen.getByTestId('card')).toBeInTheDocument();
expect(screen.getByText('Title')).toBeInTheDocument();
expect(screen.getByText('Description')).toBeInTheDocument();
expect(screen.getByText('Content')).toBeInTheDocument();
expect(screen.getByText('Footer')).toBeInTheDocument();
});
it('applies custom className to Card', () => {
render(<Card data-testid="card" className="custom">Content</Card>);
expect(screen.getByTestId('card')).toHaveClass('custom');
expect(screen.getByTestId('card')).toHaveClass('rounded-lg');
});
it('renders CardTitle as h3', () => {
render(<CardTitle>My Title</CardTitle>);
expect(screen.getByRole('heading', { level: 3 })).toHaveTextContent('My Title');
});
it('renders CardDescription as paragraph', () => {
render(<CardDescription>My Description</CardDescription>);
expect(screen.getByText('My Description').tagName).toBe('P');
});
});