forked from eatvio/eatvio_app
chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
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/features/settings/entities/settings_entity.dart';
|
||||
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
|
||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/pages/change_email_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
|
||||
import 'change_email_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([SettingsCubit])
|
||||
void main() {
|
||||
group('ChangeEmailScreen', () {
|
||||
setUpAll(() async {
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
});
|
||||
|
||||
Widget createTestWidget(SettingsEntity settingsEntity) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: ChangeEmailScreen(settingsEntity: settingsEntity),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays app bar with correct title', (WidgetTester tester) async {
|
||||
final mockCubit = MockSettingsCubit();
|
||||
final settingsEntity = SettingsEntity(
|
||||
profileSettingsModel: const ProfileSettingsModel(
|
||||
newUpdatesNotifications: true,
|
||||
diaryReminderNotifications: true,
|
||||
isMoodFillable: true,
|
||||
isBedtimeFillable: true,
|
||||
isPublicProfile: true,
|
||||
),
|
||||
profileDetailsModel: const ProfileDetailsModel(
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
birthdate: '1990-01-01',
|
||||
gender: 'male',
|
||||
country: 'Russia',
|
||||
city: 'Moscow',
|
||||
lang: 'ru',
|
||||
weight: 75.0,
|
||||
height: 180,
|
||||
chestCircumference: 100,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 90,
|
||||
bloodPressureUp: 120,
|
||||
bloodPressureDown: 80,
|
||||
hasHypo: false,
|
||||
hasHyper: false,
|
||||
aboutAlergy: 'None',
|
||||
aboutTakingPils: 'None',
|
||||
aboutSportHobbies: 'Running',
|
||||
favoriteFoods: 'Pizza',
|
||||
unfavoriteFoods: 'Broccoli',
|
||||
additionalInfo: 'No additional info',
|
||||
isMoodFillable: true,
|
||||
isBedtimeFillable: true,
|
||||
activityCoefficient: 1.5,
|
||||
),
|
||||
settingsCubit: mockCubit,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(settingsEntity));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Смена Email-a'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays coming soon message', (WidgetTester tester) async {
|
||||
final mockCubit = MockSettingsCubit();
|
||||
final settingsEntity = SettingsEntity(
|
||||
profileSettingsModel: const ProfileSettingsModel(
|
||||
newUpdatesNotifications: true,
|
||||
diaryReminderNotifications: true,
|
||||
isMoodFillable: true,
|
||||
isBedtimeFillable: true,
|
||||
isPublicProfile: true,
|
||||
),
|
||||
profileDetailsModel: const ProfileDetailsModel(
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
birthdate: '1990-01-01',
|
||||
gender: 'male',
|
||||
country: 'Russia',
|
||||
city: 'Moscow',
|
||||
lang: 'ru',
|
||||
weight: 75.0,
|
||||
height: 180,
|
||||
chestCircumference: 100,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 90,
|
||||
bloodPressureUp: 120,
|
||||
bloodPressureDown: 80,
|
||||
hasHypo: false,
|
||||
hasHyper: false,
|
||||
aboutAlergy: 'None',
|
||||
aboutTakingPils: 'None',
|
||||
aboutSportHobbies: 'Running',
|
||||
favoriteFoods: 'Pizza',
|
||||
unfavoriteFoods: 'Broccoli',
|
||||
additionalInfo: 'No additional info',
|
||||
isMoodFillable: true,
|
||||
isBedtimeFillable: true,
|
||||
activityCoefficient: 1.5,
|
||||
),
|
||||
settingsCubit: mockCubit,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(settingsEntity));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Coming soon...'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('creates ChangeEmailScreen with settingsEntity', (WidgetTester tester) async {
|
||||
final mockCubit = MockSettingsCubit();
|
||||
final settingsEntity = SettingsEntity(
|
||||
profileSettingsModel: const ProfileSettingsModel(
|
||||
newUpdatesNotifications: false,
|
||||
diaryReminderNotifications: false,
|
||||
isMoodFillable: false,
|
||||
isBedtimeFillable: false,
|
||||
isPublicProfile: false,
|
||||
),
|
||||
profileDetailsModel: const ProfileDetailsModel(
|
||||
firstName: 'Jane',
|
||||
lastName: 'Smith',
|
||||
birthdate: '1995-05-15',
|
||||
gender: 'female',
|
||||
country: 'USA',
|
||||
city: 'New York',
|
||||
lang: 'en',
|
||||
weight: 60.0,
|
||||
height: 165,
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 70,
|
||||
hipCircumference: 85,
|
||||
bloodPressureUp: 110,
|
||||
bloodPressureDown: 70,
|
||||
hasHypo: true,
|
||||
hasHyper: false,
|
||||
aboutAlergy: 'Peanuts',
|
||||
aboutTakingPils: 'Vitamins',
|
||||
aboutSportHobbies: 'Yoga',
|
||||
favoriteFoods: 'Salad',
|
||||
unfavoriteFoods: 'Fast food',
|
||||
additionalInfo: 'Vegetarian',
|
||||
isMoodFillable: false,
|
||||
isBedtimeFillable: false,
|
||||
activityCoefficient: 1.2,
|
||||
),
|
||||
settingsCubit: mockCubit,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(settingsEntity));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(ChangeEmailScreen), findsOneWidget);
|
||||
expect(find.text('Coming soon...'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user