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:
@@ -1,30 +1,107 @@
|
||||
import 'package:eatvio_app/features/profile/models/profile_model.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:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'settings_entity_test.mocks.dart';
|
||||
class MockSettingsCubit extends Mock implements SettingsCubit {}
|
||||
|
||||
@GenerateNiceMocks([MockSpec<ProfileSettingsModel>(), MockSpec<ProfileDetailsModel>(), MockSpec<SettingsCubit>()])
|
||||
void main() {
|
||||
group('SettingsEntity', () {
|
||||
test('создает SettingsEntity с правильными значениями', () {
|
||||
final mockSettings = MockProfileSettingsModel();
|
||||
final mockDetails = MockProfileDetailsModel();
|
||||
test('creates SettingsEntity with all parameters', () {
|
||||
final mockCubit = MockSettingsCubit();
|
||||
const profileSettings = ProfileSettingsModel(
|
||||
newUpdatesNotifications: true,
|
||||
diaryReminderNotifications: true,
|
||||
isMoodFillable: true,
|
||||
isBedtimeFillable: true,
|
||||
isPublicProfile: true,
|
||||
);
|
||||
const profileDetails = 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,
|
||||
);
|
||||
|
||||
final entity = SettingsEntity(
|
||||
profileSettingsModel: mockSettings,
|
||||
profileDetailsModel: mockDetails,
|
||||
profileSettingsModel: profileSettings,
|
||||
profileDetailsModel: profileDetails,
|
||||
settingsCubit: mockCubit,
|
||||
);
|
||||
|
||||
expect(entity.profileSettingsModel, mockSettings);
|
||||
expect(entity.profileDetailsModel, mockDetails);
|
||||
expect(entity.profileSettingsModel, profileSettings);
|
||||
expect(entity.profileDetailsModel, profileDetails);
|
||||
expect(entity.settingsCubit, mockCubit);
|
||||
});
|
||||
|
||||
test('creates SettingsEntity with different values', () {
|
||||
final mockCubit = MockSettingsCubit();
|
||||
const profileSettings = ProfileSettingsModel(
|
||||
newUpdatesNotifications: false,
|
||||
diaryReminderNotifications: false,
|
||||
isMoodFillable: false,
|
||||
isBedtimeFillable: false,
|
||||
isPublicProfile: false,
|
||||
);
|
||||
const profileDetails = 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,
|
||||
);
|
||||
|
||||
final entity = SettingsEntity(
|
||||
profileSettingsModel: profileSettings,
|
||||
profileDetailsModel: profileDetails,
|
||||
settingsCubit: mockCubit,
|
||||
);
|
||||
|
||||
expect(entity.profileSettingsModel.isPublicProfile, false);
|
||||
expect(entity.profileDetailsModel.firstName, 'Jane');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,30 +3,80 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('OAuthAttachRequest', () {
|
||||
test('создает OAuthAttachRequest с правильными значениями', () {
|
||||
const model = OAuthAttachRequest(
|
||||
provider: 'yandex',
|
||||
clientId: 'client-123',
|
||||
accessToken: 'access-token',
|
||||
refreshToken: 'refresh-token',
|
||||
test('creates OAuthAttachRequest with all parameters', () {
|
||||
const request = OAuthAttachRequest(
|
||||
provider: 'google',
|
||||
clientId: 'client123',
|
||||
accessToken: 'access_token_123',
|
||||
refreshToken: 'refresh_token_123',
|
||||
);
|
||||
|
||||
expect(model.provider, 'yandex');
|
||||
expect(model.clientId, 'client-123');
|
||||
expect(model.accessToken, 'access-token');
|
||||
expect(model.refreshToken, 'refresh-token');
|
||||
expect(request.provider, 'google');
|
||||
expect(request.clientId, 'client123');
|
||||
expect(request.accessToken, 'access_token_123');
|
||||
expect(request.refreshToken, 'refresh_token_123');
|
||||
});
|
||||
|
||||
test('создает OAuthAttachRequest без clientId', () {
|
||||
const model = OAuthAttachRequest(
|
||||
provider: 'yandex',
|
||||
test('creates OAuthAttachRequest with null clientId', () {
|
||||
const request = OAuthAttachRequest(
|
||||
provider: 'facebook',
|
||||
clientId: null,
|
||||
accessToken: 'access-token',
|
||||
refreshToken: 'refresh-token',
|
||||
accessToken: 'access_token_456',
|
||||
refreshToken: 'refresh_token_456',
|
||||
);
|
||||
|
||||
expect(model.clientId, isNull);
|
||||
expect(request.provider, 'facebook');
|
||||
expect(request.clientId, null);
|
||||
expect(request.accessToken, 'access_token_456');
|
||||
expect(request.refreshToken, 'refresh_token_456');
|
||||
});
|
||||
|
||||
test('creates OAuthAttachRequest from JSON with clientId', () {
|
||||
final json = {
|
||||
'provider': 'google',
|
||||
'client_id': 'client123',
|
||||
'access_token': 'access_token_123',
|
||||
'refresh_token': 'refresh_token_123',
|
||||
};
|
||||
|
||||
final request = OAuthAttachRequest.fromJson(json);
|
||||
|
||||
expect(request.provider, 'google');
|
||||
expect(request.clientId, 'client123');
|
||||
expect(request.accessToken, 'access_token_123');
|
||||
expect(request.refreshToken, 'refresh_token_123');
|
||||
});
|
||||
|
||||
test('creates OAuthAttachRequest from JSON without clientId', () {
|
||||
final json = {
|
||||
'provider': 'facebook',
|
||||
'access_token': 'access_token_456',
|
||||
'refresh_token': 'refresh_token_456',
|
||||
};
|
||||
|
||||
final request = OAuthAttachRequest.fromJson(json);
|
||||
|
||||
expect(request.provider, 'facebook');
|
||||
expect(request.clientId, null);
|
||||
expect(request.accessToken, 'access_token_456');
|
||||
expect(request.refreshToken, 'refresh_token_456');
|
||||
});
|
||||
|
||||
test('creates OAuthAttachRequest with different providers', () {
|
||||
const googleRequest = OAuthAttachRequest(
|
||||
provider: 'google',
|
||||
accessToken: 'token1',
|
||||
refreshToken: 'refresh1',
|
||||
);
|
||||
|
||||
const facebookRequest = OAuthAttachRequest(
|
||||
provider: 'facebook',
|
||||
accessToken: 'token2',
|
||||
refreshToken: 'refresh2',
|
||||
);
|
||||
|
||||
expect(googleRequest.provider, 'google');
|
||||
expect(facebookRequest.provider, 'facebook');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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