이벤트 가져오기 위젯 테스트 추가 및 테스트 훅 도입
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
@@ -13,6 +12,7 @@ import 'package:lanebow/services/event_bus.dart';
|
||||
import 'package:lanebow/utils/test_utils.dart';
|
||||
|
||||
import 'club_service_integration_test.mocks.dart';
|
||||
import '../utils/event_bus_test_utils.dart';
|
||||
|
||||
@GenerateMocks([ApiService])
|
||||
void main() {
|
||||
@@ -20,11 +20,11 @@ void main() {
|
||||
late MockApiService mockApiService;
|
||||
late String testId;
|
||||
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
// 테스트 ID 생성 및 설정
|
||||
testId = 'club_service_integration_test_${DateTime.now().millisecondsSinceEpoch}';
|
||||
EventBus.setCurrentTestId(testId);
|
||||
TestUtils.setTestMode(true);
|
||||
await EventBusTestUtils.setUp(testId);
|
||||
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({
|
||||
@@ -48,10 +48,10 @@ void main() {
|
||||
print('EventBus: 초기화됨 (테스트 ID: $testId)');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tearDown(() async {
|
||||
// 테스트 종료 후 정리
|
||||
clubService.dispose();
|
||||
EventBus.clearCurrentTestId();
|
||||
await EventBusTestUtils.tearDown();
|
||||
TestUtils.setTestMode(false);
|
||||
print('EventBus: 초기화됨 (테스트 ID: $testId)');
|
||||
});
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
// API 응답 모킹
|
||||
when(mockApiService.setToken(token)).thenReturn(null);
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: {'clubId': clubId},
|
||||
)).thenAnswer((_) async => {
|
||||
'id': clubId,
|
||||
@@ -133,7 +133,7 @@ void main() {
|
||||
|
||||
// API 응답 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: {'clubId': clubId},
|
||||
)).thenAnswer((_) async => {
|
||||
'id': clubId,
|
||||
@@ -164,7 +164,7 @@ void main() {
|
||||
|
||||
// API 응답 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: {'clubId': clubId},
|
||||
)).thenAnswer((_) async => {
|
||||
'id': clubId,
|
||||
@@ -200,7 +200,7 @@ void main() {
|
||||
)).thenAnswer((_) async => {'success': true});
|
||||
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: {'clubId': clubId},
|
||||
)).thenAnswer((_) async => {
|
||||
'id': clubId,
|
||||
@@ -252,7 +252,7 @@ void main() {
|
||||
|
||||
// API 응답 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: anyNamed('data'),
|
||||
)).thenAnswer((_) async => {
|
||||
'club': {
|
||||
@@ -358,7 +358,7 @@ void main() {
|
||||
|
||||
// API 에러 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: {'clubId': clubId},
|
||||
)).thenThrow(Exception('API 에러 발생'));
|
||||
|
||||
@@ -388,7 +388,7 @@ void main() {
|
||||
|
||||
// API 에러 모킹
|
||||
when(mockApiService.post(
|
||||
'${ApiConfig.clubs}',
|
||||
ApiConfig.clubs,
|
||||
data: anyNamed('data'),
|
||||
)).thenThrow(Exception('클럽 생성 실패'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user