forked from eatvio/eatvio_app
feat(tests): test coverage is 70.4
This commit is contained in:
@@ -26,6 +26,26 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(AddItemButton), findsOneWidget);
|
||||
expect(find.byIcon(Icons.add_rounded), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onTap when provided', (tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
AddItemButton(
|
||||
onTap: () {
|
||||
tapped = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byType(AddItemButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(tapped, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,5 +27,43 @@ void main() {
|
||||
expect(find.byType(AnimatedOptionButton), findsOneWidget);
|
||||
expect(find.text('Option 2'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders animated option button with custom text style', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
AnimatedOptionButton(
|
||||
text: 'Option 3',
|
||||
isSelected: false,
|
||||
onTap: () {},
|
||||
textStyle: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(AnimatedOptionButton), findsOneWidget);
|
||||
expect(find.text('Option 3'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onTap when button is tapped', (tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
AnimatedOptionButton(
|
||||
text: 'Option 4',
|
||||
isSelected: false,
|
||||
onTap: () {
|
||||
tapped = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byType(AnimatedOptionButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(tapped, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,69 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(BookmarkButton), findsOneWidget);
|
||||
expect(find.byIcon(Icons.bookmark), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders bookmark button with custom shape', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
BookmarkButton(
|
||||
onTap: () {},
|
||||
color: Colors.white,
|
||||
isFavorite: false,
|
||||
width: 40,
|
||||
height: 40,
|
||||
size: 20,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(BookmarkButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders bookmark button with borderRadius', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
BookmarkButton(
|
||||
onTap: () {},
|
||||
color: Colors.white,
|
||||
isFavorite: false,
|
||||
width: 40,
|
||||
height: 40,
|
||||
size: 20,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(BookmarkButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onTap when button is tapped', (tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
BookmarkButton(
|
||||
onTap: () {
|
||||
tapped = true;
|
||||
},
|
||||
color: Colors.white,
|
||||
isFavorite: false,
|
||||
width: 40,
|
||||
height: 40,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byType(BookmarkButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(tapped, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,5 +45,44 @@ void main() {
|
||||
expect(find.byType(BottomSheetActionWidget), findsOneWidget);
|
||||
expect(find.text('Test Action'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders bottom sheet action widget with custom color', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
BottomSheetActionWidget(
|
||||
text: 'Test Action',
|
||||
iconPath: 'assets/icons/ok.svg',
|
||||
onTap: () {},
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(BottomSheetActionWidget), findsOneWidget);
|
||||
expect(find.text('Test Action'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onTap when widget is tapped', (tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
BottomSheetActionWidget(
|
||||
text: 'Test Action',
|
||||
iconPath: 'assets/icons/ok.svg',
|
||||
onTap: () {
|
||||
tapped = true;
|
||||
},
|
||||
needToPop: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byType(BottomSheetActionWidget));
|
||||
await tester.pump();
|
||||
|
||||
expect(tapped, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,16 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(BottomSheetHandlerBar), findsOneWidget);
|
||||
expect(find.byType(Container), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('renders handler bar with correct dimensions', (tester) async {
|
||||
await tester.pumpWidget(wrap(const BottomSheetHandlerBar()));
|
||||
await tester.pump();
|
||||
|
||||
final container = tester.widget<Container>(find.byType(Container).first);
|
||||
final boxDecoration = container.decoration as BoxDecoration?;
|
||||
expect(boxDecoration?.borderRadius, isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,5 +27,33 @@ void main() {
|
||||
|
||||
expect(find.byType(CpfcContainer), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays calories value', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CpfcContainer(calories: 2000.0, proteins: 150.0, fats: 80.0, carbohydrates: 250.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('2000.0'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays proteins value', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CpfcContainer(calories: 2000.0, proteins: 150.0, fats: 80.0, carbohydrates: 250.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('150.0'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays fats value', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CpfcContainer(calories: 2000.0, proteins: 150.0, fats: 80.0, carbohydrates: 250.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('80.0'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays carbohydrates value', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CpfcContainer(calories: 2000.0, proteins: 150.0, fats: 80.0, carbohydrates: 250.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('250.0'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,15 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomDivider), findsOneWidget);
|
||||
expect(find.byType(Divider), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders divider with correct properties', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomDivider()));
|
||||
await tester.pump();
|
||||
|
||||
final divider = tester.widget<Divider>(find.byType(Divider));
|
||||
expect(divider.height, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,5 +29,34 @@ void main() {
|
||||
|
||||
expect(find.byType(CustomDropDownButton<String>), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom drop down button with hasError', (tester) async {
|
||||
const items = [DropdownMenuItem(value: 'option1', child: Text('Option 1')), DropdownMenuItem(value: 'option2', child: Text('Option 2'))];
|
||||
|
||||
await tester.pumpWidget(wrap(const CustomDropDownButton<String>(items: items, hint: Text('Select option'), hasError: true, onChanged: null)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomDropDownButton<String>), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom drop down button with isExpanded', (tester) async {
|
||||
const items = [DropdownMenuItem(value: 'option1', child: Text('Option 1')), DropdownMenuItem(value: 'option2', child: Text('Option 2'))];
|
||||
|
||||
await tester.pumpWidget(wrap(const CustomDropDownButton<String>(items: items, hint: Text('Select option'), isExpanded: true, onChanged: null)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomDropDownButton<String>), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onChanged when value is selected', (tester) async {
|
||||
const items = [DropdownMenuItem(value: 'option1', child: Text('Option 1')), DropdownMenuItem(value: 'option2', child: Text('Option 2'))];
|
||||
|
||||
await tester.pumpWidget(wrap(CustomDropDownButton<String>(items: items, hint: const Text('Select option'), onChanged: (value) {})));
|
||||
await tester.pump();
|
||||
|
||||
// Note: Testing dropdown selection in Flutter tests is complex
|
||||
// This test verifies the widget renders correctly
|
||||
expect(find.byType(CustomDropDownButton<String>), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,5 +32,24 @@ void main() {
|
||||
|
||||
expect(find.byType(CustomDropDown), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom drop down with alignment', (tester) async {
|
||||
const items = [SelectionPopupModel(id: 1, title: 'Option 1'), SelectionPopupModel(id: 2, title: 'Option 2')];
|
||||
|
||||
await tester.pumpWidget(wrap(const CustomDropDown(items: items, hintText: 'Select option', alignment: Alignment.centerLeft)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomDropDown), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom drop down with prefix', (tester) async {
|
||||
const items = [SelectionPopupModel(id: 1, title: 'Option 1'), SelectionPopupModel(id: 2, title: 'Option 2')];
|
||||
|
||||
await tester.pumpWidget(wrap(const CustomDropDown(items: items, hintText: 'Select option', prefix: Icon(Icons.search))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomDropDown), findsOneWidget);
|
||||
expect(find.byIcon(Icons.search), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,5 +34,40 @@ void main() {
|
||||
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom outlined button with right icon', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomOutlinedButton(text: 'Test Button', rightIcon: Icon(Icons.arrow_forward))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
expect(find.byIcon(Icons.arrow_forward), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom outlined button with custom alignment', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomOutlinedButton(text: 'Test Button', alignment: Alignment.centerLeft)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onPressed when button is tapped', (tester) async {
|
||||
bool pressed = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
CustomOutlinedButton(
|
||||
text: 'Test Button',
|
||||
onPressed: () {
|
||||
pressed = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.text('Test Button'));
|
||||
await tester.pump();
|
||||
|
||||
expect(pressed, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,5 +86,32 @@ void main() {
|
||||
expect(find.byType(CustomPopup), findsOneWidget);
|
||||
expect(find.byIcon(Icons.more_horiz_rounded), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom popup for author with recipe', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(const CustomPopup(isAuthor: true, path: 'test/path', userSlug: 'test-user', complainedContentType: ComplainedContent.recipe, slug: 'test-recipe')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(CustomPopup), findsOneWidget);
|
||||
expect(find.byIcon(Icons.more_horiz_rounded), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom popup for author with diet', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(const CustomPopup(isAuthor: true, path: 'test/path', userSlug: 'test-user', complainedContentType: ComplainedContent.diet, id: 1)),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(CustomPopup), findsOneWidget);
|
||||
expect(find.byIcon(Icons.more_horiz_rounded), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom popup for author with plan', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(const CustomPopup(isAuthor: true, path: 'test/path', userSlug: 'test-user', complainedContentType: ComplainedContent.plan, slug: 'test-plan')),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(CustomPopup), findsOneWidget);
|
||||
expect(find.byIcon(Icons.more_horiz_rounded), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,5 +43,55 @@ void main() {
|
||||
|
||||
expect(find.byType(CustomTextFormField), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom text form field with prefix', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomTextFormField(hintText: 'Enter text', prefix: Icon(Icons.search))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomTextFormField), findsOneWidget);
|
||||
expect(find.byIcon(Icons.search), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom text form field with suffix', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomTextFormField(hintText: 'Enter text', suffix: Icon(Icons.clear))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomTextFormField), findsOneWidget);
|
||||
expect(find.byIcon(Icons.clear), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom text form field with hasError', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomTextFormField(hintText: 'Enter text', hasError: true)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomTextFormField), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders custom text form field with readOnly', (tester) async {
|
||||
await tester.pumpWidget(wrap(const CustomTextFormField(hintText: 'Enter text', readOnly: true)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CustomTextFormField), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onChanged when text is entered', (tester) async {
|
||||
String? changedValue;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
CustomTextFormField(
|
||||
hintText: 'Enter text',
|
||||
onChanged: (value) {
|
||||
changedValue = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.enterText(find.byType(CustomTextFormField), 'test');
|
||||
await tester.pump();
|
||||
|
||||
expect(changedValue, 'test');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,5 +27,33 @@ void main() {
|
||||
|
||||
expect(find.byType(DataErrorWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays error message and reload button', (tester) async {
|
||||
await tester.pumpWidget(wrap(DataErrorWidget(onReload: () async {})));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(DataErrorWidget), findsOneWidget);
|
||||
expect(find.textContaining('Что-то пошло не так'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('calls onReload when button is tapped', (tester) async {
|
||||
bool reloadCalled = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
DataErrorWidget(
|
||||
onReload: () async {
|
||||
reloadCalled = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
final button = find.textContaining('Попробовать');
|
||||
await tester.tap(button);
|
||||
await tester.pump();
|
||||
|
||||
expect(reloadCalled, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,5 +31,42 @@ void main() {
|
||||
expect(find.byIcon(Icons.star), findsOneWidget);
|
||||
expect(find.text('Star'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders feed icon button with custom colors', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
FeedIconButton(
|
||||
icon: Icons.favorite,
|
||||
text: 'Like',
|
||||
onTap: () {},
|
||||
iconColor: Colors.red,
|
||||
backgroundColor: Colors.pink,
|
||||
textColor: Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byType(FeedIconButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calls onTap when button is tapped', (tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
FeedIconButton(
|
||||
icon: Icons.favorite,
|
||||
onTap: () {
|
||||
tapped = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byType(FeedIconButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(tapped, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:eatvio_app/core/enums/product_type.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/info_row.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -97,5 +98,39 @@ void main() {
|
||||
|
||||
expect(find.byType(InfoRow), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders info row for plan', (tester) async {
|
||||
const plan = PlanModel(
|
||||
id: 1,
|
||||
slug: 'test-plan',
|
||||
name: 'Test Plan',
|
||||
image: '/test.jpg',
|
||||
duration: 14,
|
||||
state: 'active',
|
||||
type: PlanType(slim: true, fit: false, wellness: false, behavior: false),
|
||||
details: 'Test plan description',
|
||||
packetsCount: 1,
|
||||
author: Author(
|
||||
authorSlug: 'test-author',
|
||||
authorName: 'Test Author',
|
||||
authorProfileIcon: '/test.jpg',
|
||||
authorIsMe: false,
|
||||
isEntitySubscribedByMe: false,
|
||||
authorPlaceInRating: null,
|
||||
),
|
||||
totalLikes: 10,
|
||||
totalViews: 100,
|
||||
totalComments: 5,
|
||||
wasLikedByMe: false,
|
||||
isFavorite: false,
|
||||
minPriceOfOptions: 1000,
|
||||
maxPriceOfOptions: 2000,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(wrap(const InfoRow(type: ProductType.plan, plan: plan)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(InfoRow), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,5 +40,21 @@ void main() {
|
||||
expect(find.byType(ItemWidget), findsOneWidget);
|
||||
expect(find.text('Test Item'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders item widget with custom icon size', (tester) async {
|
||||
await tester.pumpWidget(wrap(const ItemWidget(text: 'Test Item', iconSize: 30)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(ItemWidget), findsOneWidget);
|
||||
expect(find.text('Test Item'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders item widget reversed with custom icon size', (tester) async {
|
||||
await tester.pumpWidget(wrap(const ItemWidget(text: 'Test Item', reversed: true, iconSize: 25)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(ItemWidget), findsOneWidget);
|
||||
expect(find.text('Test Item'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,17 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(Loader), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.byType(SizedBox), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('renders loader with correct dimensions', (tester) async {
|
||||
await tester.pumpWidget(wrap(const Loader()));
|
||||
await tester.pump();
|
||||
|
||||
final sizedBox = tester.widget<SizedBox>(find.byType(SizedBox).first);
|
||||
expect(sizedBox.height, 42);
|
||||
expect(sizedBox.width, 42);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,5 +33,19 @@ void main() {
|
||||
|
||||
expect(find.byType(MainBackgroundBouble), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders main background bouble with custom width', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MainBackgroundBouble(width: 200.0, child: Text('Test'))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MainBackgroundBouble), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders main background bouble with custom padding', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MainBackgroundBouble(padding: EdgeInsets.all(16), child: Text('Test'))));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MainBackgroundBouble), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
43
test/core/widgets/markdown_html_widget_test.dart
Normal file
43
test/core/widgets/markdown_html_widget_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/markdown_html_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('MarkdownHtmlWidget smoke', () {
|
||||
Widget wrap(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('renders markdown html widget', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MarkdownHtmlWidget(markdownText: '# Test')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MarkdownHtmlWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders markdown html widget with custom image width', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MarkdownHtmlWidget(markdownText: '# Test', imageWidth: 200.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MarkdownHtmlWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders markdown html widget with custom text color', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MarkdownHtmlWidget(markdownText: '# Test', textColor: Colors.red)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MarkdownHtmlWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders markdown html widget with custom font size', (tester) async {
|
||||
await tester.pumpWidget(wrap(const MarkdownHtmlWidget(markdownText: '# Test', fontSize: 18.0)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(MarkdownHtmlWidget), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,93 +1,105 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/option_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.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() {
|
||||
group('OptionWidget', () {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.byType(SizedBox), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with option', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1', 'Item 2'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.text('Short'), findsOneWidget);
|
||||
expect(find.text('Description'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with personal diet', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('hides duration when disableDuration is true', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/option_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.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() {
|
||||
group('OptionWidget', () {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.byType(SizedBox), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with option', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1', 'Item 2'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.text('Short'), findsOneWidget);
|
||||
expect(find.text('Description'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with personal diet', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('hides duration when disableDuration is true', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays option items', (tester) async {
|
||||
const option = PacketOptions(items: ['Item 1', 'Item 2', 'Item 3'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.text('Item 1'), findsOneWidget);
|
||||
expect(find.text('Item 2'), findsOneWidget);
|
||||
expect(find.text('Item 3'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,5 +59,21 @@ void main() {
|
||||
|
||||
expect(find.byType(SuccessPublishedDietOrPlanBottomSheet), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays title and published text', (tester) async {
|
||||
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Test Diet', isPlan: false)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Test Diet'), findsOneWidget);
|
||||
expect(find.textContaining('опубликованна'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('displays plan published text when isPlan is true', (tester) async {
|
||||
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Test Plan', isPlan: true)));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Test Plan'), findsOneWidget);
|
||||
expect(find.textContaining('опубликован'), findsWidgets);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,5 +52,12 @@ void main() {
|
||||
|
||||
expect(find.byType(SuccessPublishedRecipeBottomSheet), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays recipe title', (tester) async {
|
||||
await tester.pumpWidget(wrap(const SuccessPublishedRecipeBottomSheet(title: 'My Recipe')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.textContaining('My Recipe'), findsWidgets);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user