이벤트 가져오기 위젯 테스트 추가 및 테스트 훅 도입
This commit is contained in:
@@ -6,19 +6,18 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:lanebow/services/api_service.dart';
|
||||
import 'package:lanebow/services/event_service.dart';
|
||||
import 'package:lanebow/config/api_config.dart';
|
||||
import 'package:lanebow/services/event_bus.dart';
|
||||
import 'package:lanebow/utils/test_utils.dart';
|
||||
import 'package:lanebow/models/team_model.dart';
|
||||
import 'package:lanebow/models/event_model.dart';
|
||||
|
||||
import 'event_service_integration_test.mocks.dart';
|
||||
import '../utils/event_bus_test_utils.dart';
|
||||
|
||||
@GenerateMocks([ApiService])
|
||||
void main() {
|
||||
late EventService eventService;
|
||||
late MockApiService mockApiService;
|
||||
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({
|
||||
ApiConfig.clubIdKey: 'test_club_id' // SharedPreferences에 clubId 설정
|
||||
@@ -27,7 +26,7 @@ void main() {
|
||||
// 테스트 격리를 위한 설정
|
||||
final testId = 'event_service_integration_test_${DateTime.now().millisecondsSinceEpoch}';
|
||||
TestUtils.setTestMode(true);
|
||||
EventBus.setCurrentTestId(testId);
|
||||
await EventBusTestUtils.setUp(testId);
|
||||
|
||||
print('EventBus: 초기화됨 (테스트 ID: $testId)');
|
||||
|
||||
@@ -35,10 +34,10 @@ void main() {
|
||||
eventService = EventService.forTest(mockApiService);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tearDown(() async {
|
||||
// 테스트 종료 후 정리
|
||||
eventService.dispose();
|
||||
EventBus.clearCurrentTestId();
|
||||
await EventBusTestUtils.tearDown();
|
||||
TestUtils.setTestMode(false);
|
||||
print('EventBus: 테스트 종료');
|
||||
});
|
||||
@@ -183,8 +182,8 @@ void main() {
|
||||
|
||||
// API 응답 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}/events/participants',
|
||||
data: {'eventId': eventId},
|
||||
'${ApiConfig.clubs}/events/$eventId/participants/list',
|
||||
data: anyNamed('data'),
|
||||
)).thenAnswer((_) async => {
|
||||
'participants': [
|
||||
{
|
||||
@@ -213,8 +212,8 @@ void main() {
|
||||
expect(eventService.participants[1].name, '참가자 2');
|
||||
|
||||
verify(mockApiService.post(
|
||||
'${ApiConfig.clubs}/events/participants',
|
||||
data: {'eventId': eventId},
|
||||
'${ApiConfig.clubs}/events/$eventId/participants/list',
|
||||
data: anyNamed('data'),
|
||||
)).called(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user