forked from eatvio/eatvio_app
chore(version): update app version to 1.3.5+85 and improve test coverage reporting in CI
This commit is contained in:
101
test/features/diets/presentation/widgets/info_bouble_test.dart
Normal file
101
test/features/diets/presentation/widgets/info_bouble_test.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('InfoBouble', () {
|
||||
testWidgets('displays info bouble with children', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: InfoBouble(
|
||||
children: [
|
||||
Text('Test'),
|
||||
Icon(Icons.star),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(InfoBouble), findsOneWidget);
|
||||
expect(find.text('Test'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.star), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays with custom background color', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: InfoBouble(
|
||||
backgroundColor: Colors.blue,
|
||||
children: [
|
||||
Text('Test'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(InfoBouble), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays with custom radius', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: InfoBouble(
|
||||
radius: 20,
|
||||
children: [
|
||||
Text('Test'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(InfoBouble), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays with custom padding', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: InfoBouble(
|
||||
padding: EdgeInsets.all(16),
|
||||
children: [
|
||||
Text('Test'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(InfoBouble), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays with custom mainAxisAlignment', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
body: InfoBouble(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('Test'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(InfoBouble), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/core/di/app_config_registration.dart';
|
||||
import 'package:eatvio_app/core/enums/complained_content.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/diets/presentation/widgets/more_options.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('MoreOptions', () {
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
AppConfigRegistration.registerAppConfig(buildType: AppBuildType.tests);
|
||||
});
|
||||
|
||||
Widget createTestWidget({
|
||||
String path = 'test/path',
|
||||
ComplainedContent? complainedContentType,
|
||||
String? slug,
|
||||
int? id,
|
||||
bool? disableActions,
|
||||
}) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru'), Locale('en')],
|
||||
locale: const Locale('ru'),
|
||||
home: Scaffold(
|
||||
body: MoreOptions(
|
||||
path: path,
|
||||
complainedContentType: complainedContentType,
|
||||
slug: slug,
|
||||
id: id,
|
||||
disableActions: disableActions,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays copy link option', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(MoreOptions), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays share option', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(MoreOptions), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays complain option when complainedContentType is provided', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
id: 1,
|
||||
slug: 'test-slug',
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(MoreOptions), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('disables actions when disableActions is true', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget(disableActions: true));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(MoreOptions), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('enables actions when disableActions is false', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget(disableActions: false));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(MoreOptions), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user