Files
web-page/src/pages/listings/components/ListingsTab.test.jsx
gahusb ffd306859f test(listings): 매물 빈-상태 스모크 assertion을 버튼과 겹치지 않게 좁힘
리뷰 지적: /매물이 없습니다|수집/ 의 |수집 이 항상 존재하는 '수집 실행'
버튼과 매치 → 빈-상태 미검증. /매물이 없습니다/ 로 좁혀 실제 검증.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UHXzpsZQxKG9hQmNRfZjRS
2026-07-09 16:08:53 +09:00

37 lines
1.5 KiB
JavaScript

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();
});
});