-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsightReport.test.tsx
More file actions
82 lines (73 loc) · 3.04 KB
/
Copy pathInsightReport.test.tsx
File metadata and controls
82 lines (73 loc) · 3.04 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { describe, expect, it } from 'vitest';
import { render, screen } from '@testing-library/react';
import { InsightReport } from './InsightReport';
import type { AnalysisResult } from '@/src/features/analysis/types';
const result: AnalysisResult = {
products: [
{
url: 'https://coupang.com/a',
product_name: '무선 청소기',
total_reviews: 120,
avg_rating: 4.3,
rating_distribution: { '1': 5, '2': 5, '3': 10, '4': 40, '5': 60 },
},
],
insights: {
top_complaints: [{ text: '배터리가 빨리 닳음', count: 30, severity: 'high' }],
top_positives: [{ text: '흡입력이 강함', count: 50 }],
improvement_points: [
{ rank: 1, title: '배터리 수명 개선', detail: '교체형 배터리 제공' },
{ rank: 2, title: '무게 감소', detail: '경량 소재 적용' },
{ rank: 3, title: '소음 저감', detail: '저소음 모터 적용' },
],
competitor_weaknesses: [
{ title: '느린 충전', opportunity: '고속 충전으로 차별화' },
],
purchase_drivers: ['가성비', '디자인'],
},
};
describe('InsightReport', () => {
it('renders the top improvement points', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('배터리 수명 개선')).toBeInTheDocument();
expect(screen.getByText('무게 감소')).toBeInTheDocument();
expect(screen.getByText('소음 저감')).toBeInTheDocument();
});
it('renders competitor weaknesses', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('느린 충전')).toBeInTheDocument();
expect(screen.getByText('고속 충전으로 차별화')).toBeInTheDocument();
});
it('renders purchase drivers', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('가성비')).toBeInTheDocument();
expect(screen.getByText('디자인')).toBeInTheDocument();
});
it('renders complaints and positives', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('배터리가 빨리 닳음')).toBeInTheDocument();
expect(screen.getByText('흡입력이 강함')).toBeInTheDocument();
});
it('renders product name and rating', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('무선 청소기')).toBeInTheDocument();
expect(screen.getByText(/4\.3/)).toBeInTheDocument();
});
it('renders the methodology sample size', () => {
render(<InsightReport result={result} />);
expect(screen.getByText('분석 방법 · 데이터 출처')).toBeInTheDocument();
expect(
screen.getByText(/분석 표본: 총 120개 리뷰 \(상품 1개\)/),
).toBeInTheDocument();
});
it('renders a section description', () => {
render(<InsightReport result={result} />);
expect(
screen.getByText(/내 상품이 파고들 기회입니다/),
).toBeInTheDocument();
});
it('renders the disclaimer', () => {
render(<InsightReport result={result} />);
expect(screen.getByText(/참고용 인사이트입니다/)).toBeInTheDocument();
});
});