Files
eatvio_app/test/features/plans/presentation/widgets/options_tab_test.dart
2025-12-25 12:56:38 +03:00

42 lines
1.5 KiB
Dart

import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/plans/presentation/cubit/about_plan_cubit.dart';
import 'package:eatvio_app/features/plans/presentation/cubit/about_plan_state.dart';
import 'package:eatvio_app/features/plans/presentation/widgets/options_tab.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'options_tab_test.mocks.dart';
@GenerateNiceMocks([MockSpec<AboutPlanCubit>()])
void main() {
group('OptionsTab smoke', () {
Widget wrap(Widget child, AboutPlanCubit cubit) {
return MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: BlocProvider<AboutPlanCubit>.value(value: cubit, child: child),
),
);
}
testWidgets('renders options tab', (tester) async {
final cubit = MockAboutPlanCubit();
final state = AboutPlanState.initial();
when(cubit.state).thenReturn(state);
when(cubit.stream).thenAnswer((_) => Stream.value(state));
when(cubit.close()).thenAnswer((_) async => Future<void>.value());
when(cubit.choseOption(any)).thenReturn(null);
await tester.pumpWidget(wrap(const OptionsTab(cost: [100, 200, 300]), cubit));
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
expect(find.byType(OptionsTab), findsOneWidget);
});
});
}