97 lines
3.4 KiB
Dart
97 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:lanebow/models/event_model.dart';
|
|
import 'package:lanebow/screens/club/tabs/basic_info_tab.dart';
|
|
|
|
void main() {
|
|
Widget _wrap(Widget child) => MaterialApp(home: Scaffold(body: child));
|
|
|
|
group('BasicInfoTab 표시/숨김 테스트', () {
|
|
testWidgets('모든 항목이 있을 때 모두 표시된다', (tester) async {
|
|
final event = Event(
|
|
id: 'e1',
|
|
clubId: 'c1',
|
|
title: '타이틀',
|
|
description: '설명 텍스트',
|
|
startDate: DateTime(2025, 1, 1, 10, 0),
|
|
endDate: DateTime(2025, 1, 1, 12, 0),
|
|
location: '강남 볼링장',
|
|
type: 'regular',
|
|
status: 'active',
|
|
maxParticipants: 20,
|
|
gameCount: 3,
|
|
participantFee: 15000,
|
|
registrationDeadline: DateTime(2024, 12, 31, 23, 0),
|
|
publicHash: 'hash123',
|
|
accessPassword: 'abcd',
|
|
isActive: true,
|
|
);
|
|
|
|
await tester.pumpWidget(_wrap(BasicInfoTab(
|
|
event: event,
|
|
participantsCount: 5,
|
|
onShareEvent: () {},
|
|
onSetEventReminders: () {},
|
|
)));
|
|
await tester.pumpAndSettle();
|
|
|
|
// 설명 섹션
|
|
expect(find.text('설명'), findsOneWidget);
|
|
expect(find.text('설명 텍스트'), findsOneWidget);
|
|
|
|
// 이벤트 정보
|
|
expect(find.textContaining('시작:'), findsOneWidget);
|
|
expect(find.textContaining('종료:'), findsOneWidget);
|
|
expect(find.textContaining('장소: 강남 볼링장'), findsOneWidget);
|
|
expect(find.textContaining('최대 참가자: 20'), findsOneWidget);
|
|
expect(find.textContaining('게임 수: 3'), findsOneWidget);
|
|
expect(find.textContaining('참가비:'), findsOneWidget);
|
|
expect(find.textContaining('신청마감:'), findsOneWidget);
|
|
|
|
// 공개 접근
|
|
expect(find.textContaining('http'), findsWidgets);
|
|
expect(find.textContaining('접근 비밀번호:'), findsOneWidget);
|
|
|
|
// 참가자 정보
|
|
expect(find.text('참가자 정보'), findsOneWidget);
|
|
expect(find.textContaining('현재 참가자: 5'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('입력되지 않은 항목은 숨겨진다', (tester) async {
|
|
final event = Event(
|
|
id: 'e1',
|
|
clubId: 'c1',
|
|
title: '타이틀',
|
|
startDate: DateTime(2025, 1, 1, 10, 0),
|
|
// 나머지 선택 항목 미설정
|
|
isActive: true,
|
|
);
|
|
|
|
await tester.pumpWidget(_wrap(BasicInfoTab(
|
|
event: event,
|
|
participantsCount: 0,
|
|
onShareEvent: () {},
|
|
onSetEventReminders: () {},
|
|
)));
|
|
await tester.pumpAndSettle();
|
|
|
|
// 설명 섹션 없음
|
|
expect(find.text('설명'), findsNothing);
|
|
|
|
// 이벤트 정보: 시작만 존재, 나머지 미표시
|
|
expect(find.textContaining('시작:'), findsOneWidget);
|
|
expect(find.textContaining('종료:'), findsNothing);
|
|
expect(find.textContaining('장소:'), findsNothing);
|
|
expect(find.textContaining('최대 참가자:'), findsNothing);
|
|
expect(find.textContaining('게임 수:'), findsNothing);
|
|
expect(find.textContaining('참가비:'), findsNothing);
|
|
expect(find.textContaining('신청마감:'), findsNothing);
|
|
|
|
// 공개 접근: publicHash/비밀번호 미설정 → 표시 안 됨
|
|
expect(find.textContaining('http'), findsNothing);
|
|
expect(find.textContaining('접근 비밀번호:'), findsNothing);
|
|
});
|
|
});
|
|
}
|