feat(listings): 매물 목록 탭(필터·판정 tier·수집) + 스모크 테스트
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXzpsZQxKG9hQmNRfZjRS
This commit is contained in:
36
src/pages/listings/components/ListingsTab.test.jsx
Normal file
36
src/pages/listings/components/ListingsTab.test.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
|
||||
vi.mock('../../../api', () => ({
|
||||
getListings: vi.fn(),
|
||||
collectListings: vi.fn(),
|
||||
getListingsCollectStatus: vi.fn(),
|
||||
}));
|
||||
import { getListings, getListingsCollectStatus } from '../../../api';
|
||||
import ListingsTab from './ListingsTab.jsx';
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
getListingsCollectStatus.mockResolvedValue({ status: 'never_run' });
|
||||
});
|
||||
|
||||
describe('ListingsTab', () => {
|
||||
it('빈 목록이면 안내 문구', async () => {
|
||||
getListings.mockResolvedValue({ listings: [] });
|
||||
render(<ListingsTab />);
|
||||
await waitFor(() => expect(screen.getByText(/매물이 없습니다|수집/)).toBeInTheDocument());
|
||||
});
|
||||
|
||||
it('매물+판정 tier·배열 필드를 크래시 없이 렌더 (매매=valuation, 배열 그대로)', async () => {
|
||||
getListings.mockResolvedValue({ listings: [{
|
||||
id: 1, complex_name: '상도더샵', dong: '상도동', deal_type: '매매',
|
||||
price: 95000, valuation_tier: '고가', ratio: 1.08,
|
||||
regulation_flags: ['토지거래허가'], reasons: ['호가가 최근 실거래 대비 8% 높음'],
|
||||
}] });
|
||||
render(<ListingsTab />);
|
||||
await waitFor(() => expect(screen.getByText('상도더샵')).toBeInTheDocument());
|
||||
expect(screen.getByText(/고가/)).toBeInTheDocument();
|
||||
expect(screen.getByText('토지거래허가')).toBeInTheDocument();
|
||||
expect(screen.getByText(/호가가 최근 실거래/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user