forked from eatvio/eatvio_app
96 lines
3.2 KiB
Dart
96 lines
3.2 KiB
Dart
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/registration/models/user_registration_model.dart';
|
|
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
|
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart';
|
|
import 'package:eatvio_app/features/registration/presentation/pages/allergies_screen.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mockito/annotations.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
|
|
import 'allergies_screen_test.mocks.dart';
|
|
|
|
@GenerateNiceMocks([MockSpec<RegistrationCubit>()])
|
|
void main() {
|
|
group('AllergiesScreen smoke', () {
|
|
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'));
|
|
});
|
|
|
|
const mockSheet = UserRegistrationSheet(
|
|
firstName: '',
|
|
lastName: '',
|
|
email: '',
|
|
password: '',
|
|
passwordConfirmation: '',
|
|
birthdate: '',
|
|
gender: '',
|
|
location: '',
|
|
responseBody: '{}',
|
|
lang: 'ru',
|
|
weight: 0,
|
|
height: 0,
|
|
phone: '',
|
|
chestCircumference: 0,
|
|
waistCircumference: 0,
|
|
hipCircumference: 0,
|
|
bloodPressureUp: 0,
|
|
bloodPressureDown: 0,
|
|
hasHypo: 0,
|
|
hasHyper: 0,
|
|
aboutAllergy: '',
|
|
aboutTakingPils: '',
|
|
aboutSportHobbies: '',
|
|
favoriteFoods: '',
|
|
unfavoriteFoods: '',
|
|
additionalInfo: '',
|
|
);
|
|
|
|
Widget wrap(Widget child) {
|
|
return MaterialApp(
|
|
theme: ThemeHelper().themeData(),
|
|
localizationsDelegates: const [
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: const [Locale('ru')],
|
|
home: Scaffold(body: child),
|
|
);
|
|
}
|
|
|
|
testWidgets('renders allergies screen', (tester) async {
|
|
final cubit = MockRegistrationCubit();
|
|
const state = RegistrationState(sheet: mockSheet);
|
|
|
|
when(cubit.state).thenReturn(state);
|
|
when(cubit.stream).thenAnswer((_) => Stream.value(state));
|
|
when(cubit.close()).thenAnswer((_) async => Future<void>.value());
|
|
when(cubit.updateSheet(any)).thenReturn(null);
|
|
|
|
await tester.pumpWidget(
|
|
BlocProvider<RegistrationCubit>.value(
|
|
value: cubit,
|
|
child: wrap(const AllergiesScreen(sheet: mockSheet)),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(AllergiesScreen), findsOneWidget);
|
|
});
|
|
});
|
|
}
|