forked from eatvio/eatvio_app
test(tests): add whitespace to multiple test files for consistency and improved readability
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
import 'package:eatvio_app/core/app_config.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/widgets/cancel_diet_bottom_sheet.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_portal/flutter_portal.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'cancel_diet_bottom_sheet_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<AboutDietCubit>()])
|
||||
void main() {
|
||||
group('CancelDietBottomSheet', () {
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
});
|
||||
|
||||
Widget createTestWidget(Widget child, AboutDietCubit cubit) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru')],
|
||||
home: Portal(
|
||||
child: BlocProvider<AboutDietCubit>(
|
||||
create: (_) => cubit,
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('should display cancel diet bottom sheet with default title', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final mockCubit = MockAboutDietCubit();
|
||||
final widget = CancelDietBottomSheet(
|
||||
aboutDietCubit: mockCubit,
|
||||
);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget, mockCubit));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(CancelDietBottomSheet), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display cancel diet bottom sheet with custom title', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final mockCubit = MockAboutDietCubit();
|
||||
final widget = CancelDietBottomSheet(
|
||||
aboutDietCubit: mockCubit,
|
||||
title: 'Custom title',
|
||||
);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget, mockCubit));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(CancelDietBottomSheet), findsOneWidget);
|
||||
expect(find.text('Custom title'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display cancel diet bottom sheet with diet name', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final mockCubit = MockAboutDietCubit();
|
||||
final widget = CancelDietBottomSheet(
|
||||
aboutDietCubit: mockCubit,
|
||||
dietName: 'Test Diet',
|
||||
);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget, mockCubit));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(CancelDietBottomSheet), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,3 +106,4 @@ void main() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:eatvio_app/core/app_config.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/widgets/start_diet_bottom_sheet.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_portal/flutter_portal.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'start_diet_bottom_sheet_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<AboutDietCubit>()])
|
||||
void main() {
|
||||
group('StartDietBottomSheet', () {
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
});
|
||||
|
||||
Widget createTestWidget(Widget child, AboutDietCubit cubit) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru')],
|
||||
home: Portal(
|
||||
child: BlocProvider<AboutDietCubit>(
|
||||
create: (_) => cubit,
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('should display start diet bottom sheet', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final mockCubit = MockAboutDietCubit();
|
||||
final widget = StartDietBottomSheet(
|
||||
aboutDietCubit: mockCubit,
|
||||
);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget, mockCubit));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(StartDietBottomSheet), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user