forked from eatvio/eatvio_app
48 lines
1.9 KiB
Dart
48 lines
1.9 KiB
Dart
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/widgets/notification_banner.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_test/flutter_test.dart';
|
|
import 'package:mockito/annotations.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
|
|
import 'notification_banner_test.mocks.dart';
|
|
|
|
@GenerateNiceMocks([MockSpec<ChatRoomCubit>()])
|
|
void main() {
|
|
group('NotificationBanner smoke', () {
|
|
Widget wrap(Widget child, ChatRoomCubit? cubit) {
|
|
return MaterialApp(
|
|
theme: ThemeHelper().themeData(),
|
|
localizationsDelegates: const [
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: const [Locale('ru')],
|
|
home: Scaffold(
|
|
body: cubit != null ? BlocProvider<ChatRoomCubit>.value(value: cubit, child: child) : child,
|
|
),
|
|
);
|
|
}
|
|
|
|
testWidgets('renders notification banner - date type', (tester) async {
|
|
final cubit = MockChatRoomCubit();
|
|
const state = ChatRoomState.loading();
|
|
when(cubit.state).thenReturn(state);
|
|
when(cubit.stream).thenAnswer((_) => Stream.value(state));
|
|
when(cubit.close()).thenAnswer((_) async => Future<void>.value());
|
|
|
|
await tester.pumpWidget(wrap(const NotificationBanner(bannerType: BannerType.date, hasPersonalDiet: false), cubit));
|
|
await tester.pump();
|
|
|
|
expect(find.byType(NotificationBanner), findsOneWidget);
|
|
});
|
|
});
|
|
}
|