공개페이지
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lanebow/screens/public_event/public_event_screen.dart';
|
||||
import 'package:lanebow/services/public_event_service.dart';
|
||||
|
||||
class StubFetchService extends PublicEventService {
|
||||
@override
|
||||
Future<Map<String, dynamic>> fetchEvent(String publicHash) async {
|
||||
return {
|
||||
'event': {'id': 'E100', 'title': '오픈 리그'},
|
||||
'participants': [
|
||||
{'participantId': '1', 'name': 'Kim'},
|
||||
{'participantId': '2', 'name': 'Lee'},
|
||||
],
|
||||
'teams': [
|
||||
{'teamId': 'T1'},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('renders title and counts from fetchEvent', (tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: PublicEventScreen(publicHash: 'abc', service: StubFetchService()),
|
||||
));
|
||||
|
||||
// initial loading
|
||||
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('event_title')), findsOneWidget);
|
||||
expect(find.text('오픈 리그'), findsOneWidget);
|
||||
expect(find.byKey(const Key('participants_count')), findsOneWidget);
|
||||
final pc = tester.widget<Text>(find.byKey(const Key('participants_count')));
|
||||
expect(pc.data, '총 2명');
|
||||
expect(find.byKey(const Key('teams_count')), findsOneWidget);
|
||||
expect(find.text('총 1팀'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user