forked from eatvio/eatvio_app
refactor(tests): replace 'final' with 'const' for improved performance in various test files
This commit is contained in:
@@ -18,7 +18,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates loaded state with comment', () {
|
||||
final comment = CommentModel(
|
||||
const comment = CommentModel(
|
||||
data: [],
|
||||
links: Links(first: '', last: '', prev: null, next: null),
|
||||
meta: Meta(
|
||||
@@ -33,14 +33,14 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final state = CommentsState.loaded(comment: comment);
|
||||
const state = CommentsState.loaded(comment: comment);
|
||||
|
||||
expect(state, isA<CommentsStateLoaded>());
|
||||
expect((state as CommentsStateLoaded).comment, comment);
|
||||
});
|
||||
|
||||
test('creates loaded state with replyId', () {
|
||||
final comment = CommentModel(
|
||||
const comment = CommentModel(
|
||||
data: [],
|
||||
links: Links(first: '', last: '', prev: null, next: null),
|
||||
meta: Meta(
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final state = CommentsState.loaded(
|
||||
const state = CommentsState.loaded(
|
||||
comment: comment,
|
||||
replyId: 123,
|
||||
);
|
||||
@@ -64,7 +64,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates loaded state with editedCommentId', () {
|
||||
final comment = CommentModel(
|
||||
const comment = CommentModel(
|
||||
data: [],
|
||||
links: Links(first: '', last: '', prev: null, next: null),
|
||||
meta: Meta(
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final state = CommentsState.loaded(
|
||||
const state = CommentsState.loaded(
|
||||
comment: comment,
|
||||
editedCommentId: 456,
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
|
||||
@@ -31,17 +31,17 @@ void main() {
|
||||
|
||||
group('Animations', () {
|
||||
test('has correct animation durations', () {
|
||||
expect(AppConstants.defaultAnimationDuration, Duration(milliseconds: 300));
|
||||
expect(AppConstants.fastAnimationDuration, Duration(milliseconds: 150));
|
||||
expect(AppConstants.slowAnimationDuration, Duration(milliseconds: 500));
|
||||
expect(AppConstants.defaultAnimationDuration, const Duration(milliseconds: 300));
|
||||
expect(AppConstants.fastAnimationDuration, const Duration(milliseconds: 150));
|
||||
expect(AppConstants.slowAnimationDuration, const Duration(milliseconds: 500));
|
||||
});
|
||||
});
|
||||
|
||||
group('Timeouts', () {
|
||||
test('has correct timeout durations', () {
|
||||
expect(AppConstants.defaultTimeout, Duration(seconds: 30));
|
||||
expect(AppConstants.shortTimeout, Duration(seconds: 10));
|
||||
expect(AppConstants.longTimeout, Duration(minutes: 2));
|
||||
expect(AppConstants.defaultTimeout, const Duration(seconds: 30));
|
||||
expect(AppConstants.shortTimeout, const Duration(seconds: 10));
|
||||
expect(AppConstants.longTimeout, const Duration(minutes: 2));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -127,4 +127,3 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestCubit extends BaseCubit<String> {
|
||||
|
||||
Future<String?> executeOperation() async {
|
||||
return await safeExecute(() async {
|
||||
await Future.delayed(Duration(milliseconds: 10));
|
||||
await Future.delayed(const Duration(milliseconds: 10));
|
||||
return 'success';
|
||||
});
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class TestCubit extends BaseCubit<String> {
|
||||
Future<String?> executeOperationWithState() async {
|
||||
return await safeExecuteWithState(
|
||||
() async {
|
||||
await Future.delayed(Duration(milliseconds: 10));
|
||||
await Future.delayed(const Duration(milliseconds: 10));
|
||||
return 'result';
|
||||
},
|
||||
loadingState: 'loading',
|
||||
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('getErrorMessage extracts error message from error state', () {
|
||||
final errorState = 'error: Something went wrong';
|
||||
const errorState = 'error: Something went wrong';
|
||||
final message = StateUtils.getErrorMessage(errorState);
|
||||
expect(message, isNotNull);
|
||||
expect(message, contains('Something'));
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
group('SelectionPopupModel', () {
|
||||
test('creates model with all parameters', () {
|
||||
final model = SelectionPopupModel(
|
||||
const model = SelectionPopupModel(
|
||||
id: 1,
|
||||
title: 'Test Title',
|
||||
value: 'Test Value',
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates model with default isSelected value', () {
|
||||
final model = SelectionPopupModel(
|
||||
const model = SelectionPopupModel(
|
||||
title: 'Test Title',
|
||||
value: 'Test Value',
|
||||
);
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates model with null id', () {
|
||||
final model = SelectionPopupModel(
|
||||
const model = SelectionPopupModel(
|
||||
id: null,
|
||||
title: 'Test Title',
|
||||
value: 'Test Value',
|
||||
@@ -38,17 +38,17 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates model with different value types', () {
|
||||
final model1 = SelectionPopupModel(
|
||||
const model1 = SelectionPopupModel(
|
||||
title: 'Test',
|
||||
value: 123,
|
||||
);
|
||||
|
||||
final model2 = SelectionPopupModel(
|
||||
const model2 = SelectionPopupModel(
|
||||
title: 'Test',
|
||||
value: 'String Value',
|
||||
);
|
||||
|
||||
final model3 = SelectionPopupModel(
|
||||
const model3 = SelectionPopupModel(
|
||||
title: 'Test',
|
||||
value: true,
|
||||
);
|
||||
@@ -59,13 +59,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('can be compared', () {
|
||||
final model1 = SelectionPopupModel(
|
||||
const model1 = SelectionPopupModel(
|
||||
id: 1,
|
||||
title: 'Test',
|
||||
value: 'Value',
|
||||
);
|
||||
|
||||
final model2 = SelectionPopupModel(
|
||||
const model2 = SelectionPopupModel(
|
||||
id: 1,
|
||||
title: 'Test',
|
||||
value: 'Value',
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
group('Links', () {
|
||||
test('creates Links with all parameters', () {
|
||||
final links = Links(
|
||||
const links = Links(
|
||||
first: 'http://example.com?page=1',
|
||||
last: 'http://example.com?page=10',
|
||||
prev: 'http://example.com?page=2',
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates Links with null prev and next', () {
|
||||
final links = Links(
|
||||
const links = Links(
|
||||
first: 'http://example.com?page=1',
|
||||
last: 'http://example.com?page=10',
|
||||
prev: null,
|
||||
@@ -32,7 +32,7 @@ void main() {
|
||||
|
||||
group('Link', () {
|
||||
test('creates Link with all parameters', () {
|
||||
final link = Link(
|
||||
const link = Link(
|
||||
url: 'http://example.com?page=1',
|
||||
label: '1',
|
||||
active: true,
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates Link with null values', () {
|
||||
final link = Link(
|
||||
const link = Link(
|
||||
url: null,
|
||||
label: null,
|
||||
active: null,
|
||||
@@ -58,7 +58,7 @@ void main() {
|
||||
|
||||
group('Meta', () {
|
||||
test('creates Meta with all parameters', () {
|
||||
final meta = Meta(
|
||||
const meta = Meta(
|
||||
currentPage: 1,
|
||||
from: 1,
|
||||
lastPage: 10,
|
||||
@@ -80,7 +80,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates Meta with null optional values', () {
|
||||
final meta = Meta(
|
||||
const meta = Meta(
|
||||
currentPage: 1,
|
||||
from: null,
|
||||
lastPage: 10,
|
||||
@@ -99,12 +99,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('creates Meta with links list', () {
|
||||
final links = [
|
||||
const links = [
|
||||
Link(url: 'http://example.com?page=1', label: '1', active: true),
|
||||
Link(url: 'http://example.com?page=2', label: '2', active: false),
|
||||
];
|
||||
|
||||
final meta = Meta(
|
||||
const meta = Meta(
|
||||
currentPage: 1,
|
||||
from: 1,
|
||||
lastPage: 10,
|
||||
|
||||
@@ -165,19 +165,19 @@ void main() {
|
||||
});
|
||||
|
||||
test('primaryColorScheme has primary color', () {
|
||||
final colorScheme = ColorSchemes.primaryColorScheme;
|
||||
const colorScheme = ColorSchemes.primaryColorScheme;
|
||||
|
||||
expect(colorScheme.primary, isA<Color>());
|
||||
});
|
||||
|
||||
test('primaryColorScheme has onPrimary color', () {
|
||||
final colorScheme = ColorSchemes.primaryColorScheme;
|
||||
const colorScheme = ColorSchemes.primaryColorScheme;
|
||||
|
||||
expect(colorScheme.onPrimary, isA<Color>());
|
||||
});
|
||||
|
||||
test('primaryColorScheme has onPrimaryContainer color', () {
|
||||
final colorScheme = ColorSchemes.primaryColorScheme;
|
||||
const colorScheme = ColorSchemes.primaryColorScheme;
|
||||
|
||||
expect(colorScheme.onPrimaryContainer, isA<Color>());
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ void main() {
|
||||
);
|
||||
|
||||
// Scroll to trigger notification
|
||||
await tester.drag(find.byType(SingleChildScrollView), Offset(0, -100));
|
||||
await tester.drag(find.byType(SingleChildScrollView), const Offset(0, -100));
|
||||
await tester.pump();
|
||||
|
||||
expect(loadNewContent, isA<Function>());
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: AddItemButton(),
|
||||
),
|
||||
),
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: AddItemButton(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
text: 'Option 1',
|
||||
isSelected: false,
|
||||
onTap: () {},
|
||||
textStyle: TextStyle(fontSize: 20),
|
||||
textStyle: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -27,12 +27,12 @@ void main() {
|
||||
body: BaseButton(
|
||||
text: 'Test Button',
|
||||
onPressed: () {},
|
||||
buttonStyle: ButtonStyle(),
|
||||
buttonTextStyle: TextStyle(),
|
||||
buttonStyle: const ButtonStyle(),
|
||||
buttonTextStyle: const TextStyle(),
|
||||
isDisabled: false,
|
||||
height: 50.0,
|
||||
width: 100.0,
|
||||
margin: EdgeInsets.all(10),
|
||||
margin: const EdgeInsets.all(10),
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: BottomSheetHandlerBar(),
|
||||
),
|
||||
),
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: BottomSheetHandlerBar(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -16,10 +16,10 @@ void main() {
|
||||
onPressed: () {
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
child: Text('Test Content'),
|
||||
child: const Text('Test Content'),
|
||||
);
|
||||
},
|
||||
child: Text('Show Bottom Sheet'),
|
||||
child: const Text('Show Bottom Sheet'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -44,11 +44,11 @@ void main() {
|
||||
onPressed: () {
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
child: Text('Test Content'),
|
||||
child: const Text('Test Content'),
|
||||
hasBlur: false,
|
||||
);
|
||||
},
|
||||
child: Text('Show Bottom Sheet'),
|
||||
child: const Text('Show Bottom Sheet'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -73,11 +73,11 @@ void main() {
|
||||
onPressed: () {
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
child: Text('Test Content'),
|
||||
child: const Text('Test Content'),
|
||||
height: 300.0,
|
||||
);
|
||||
},
|
||||
child: Text('Show Bottom Sheet'),
|
||||
child: const Text('Show Bottom Sheet'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -102,10 +102,10 @@ void main() {
|
||||
onPressed: () {
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
child: Text('Test Content'),
|
||||
child: const Text('Test Content'),
|
||||
);
|
||||
},
|
||||
child: Text('Show Bottom Sheet'),
|
||||
child: const Text('Show Bottom Sheet'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
|
||||
expect(find.text('Test Content'), findsOneWidget);
|
||||
|
||||
await tester.tapAt(Offset(0, 0));
|
||||
await tester.tapAt(const Offset(0, 0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Test Content'), findsNothing);
|
||||
|
||||
@@ -15,7 +15,7 @@ void main() {
|
||||
}) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomDivider(),
|
||||
),
|
||||
),
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomDivider(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Form(
|
||||
child: CustomDropDownButton<String>(
|
||||
items: [
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'option1', child: Text('Option 1')),
|
||||
DropdownMenuItem(value: 'option2', child: Text('Option 2')),
|
||||
],
|
||||
@@ -35,11 +35,11 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Form(
|
||||
child: CustomDropDownButton<String>(
|
||||
items: [
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'option1', child: Text('Option 1')),
|
||||
DropdownMenuItem(value: 'option2', child: Text('Option 2')),
|
||||
],
|
||||
hint: Text('Select option'),
|
||||
hint: const Text('Select option'),
|
||||
onChanged: (value) {},
|
||||
),
|
||||
),
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Form(
|
||||
child: CustomDropDownButton<String>(
|
||||
items: [
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'option1', child: Text('Option 1')),
|
||||
DropdownMenuItem(value: 'option2', child: Text('Option 2')),
|
||||
],
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: Form(
|
||||
child: CustomDropDownButton<String>(
|
||||
items: [
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'option1', child: Text('Option 1')),
|
||||
DropdownMenuItem(value: 'option2', child: Text('Option 2')),
|
||||
],
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('CustomDropDown', () {
|
||||
final items = [
|
||||
const items = [
|
||||
SelectionPopupModel(id: 1, title: 'Option 1'),
|
||||
SelectionPopupModel(id: 2, title: 'Option 2'),
|
||||
];
|
||||
|
||||
@@ -104,7 +104,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: CustomOutlinedButton(
|
||||
text: 'Test Button',
|
||||
leftIcon: Icon(Icons.add),
|
||||
leftIcon: const Icon(Icons.add),
|
||||
buttonStyle: OutlinedButton.styleFrom(),
|
||||
onPressed: () {},
|
||||
),
|
||||
@@ -124,7 +124,7 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: CustomOutlinedButton(
|
||||
text: 'Test Button',
|
||||
rightIcon: Icon(Icons.arrow_forward),
|
||||
rightIcon: const Icon(Icons.arrow_forward),
|
||||
buttonStyle: OutlinedButton.styleFrom(),
|
||||
onPressed: () {},
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(),
|
||||
),
|
||||
),
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
hintText: 'Enter text',
|
||||
),
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
initialValue: 'Initial text',
|
||||
),
|
||||
@@ -75,7 +75,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
suffixText: 'kg',
|
||||
),
|
||||
@@ -90,7 +90,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
hasError: true,
|
||||
),
|
||||
@@ -105,7 +105,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
readOnly: true,
|
||||
initialValue: 'Read only text',
|
||||
@@ -121,7 +121,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
@@ -151,7 +151,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: CustomTextFormField(
|
||||
maxLength: 10,
|
||||
),
|
||||
|
||||
@@ -15,7 +15,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -35,13 +35,13 @@ void main() {
|
||||
|
||||
testWidgets('shows loader when reloading', (tester) async {
|
||||
Future<void> onReload() async {
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: FeedIconButton(
|
||||
icon: Icons.favorite,
|
||||
),
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: FeedIconButton(
|
||||
text: 'Like',
|
||||
),
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: FeedIconButton(
|
||||
icon: Icons.favorite,
|
||||
text: 'Like',
|
||||
@@ -97,7 +97,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: FeedIconButton(
|
||||
icon: Icons.favorite,
|
||||
),
|
||||
|
||||
@@ -11,7 +11,7 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
testWidgets('displays info row widget', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
InfoRow(
|
||||
const InfoRow(
|
||||
type: ProductType.diet,
|
||||
),
|
||||
),
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
testWidgets('displays info row for plan type', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
InfoRow(
|
||||
const InfoRow(
|
||||
type: ProductType.plan,
|
||||
),
|
||||
),
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
testWidgets('displays info row for recipe type', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
InfoRow(
|
||||
const InfoRow(
|
||||
type: ProductType.recipe,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: ItemWidget(text: 'Test item'),
|
||||
),
|
||||
),
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: ItemWidget(text: 'Test item', reversed: true),
|
||||
),
|
||||
),
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: ItemWidget(text: 'Test item', iconSize: 30),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -6,7 +6,7 @@ void main() {
|
||||
group('Loader', () {
|
||||
testWidgets('displays loader widget', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Loader(),
|
||||
),
|
||||
@@ -19,7 +19,7 @@ void main() {
|
||||
|
||||
testWidgets('has correct dimensions', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Loader(),
|
||||
),
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: MainBackgroundBouble(
|
||||
child: Text('Test'),
|
||||
),
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: MainBackgroundBouble(
|
||||
width: 200,
|
||||
child: Text('Test'),
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: MainBackgroundBouble(
|
||||
enableShadow: true,
|
||||
child: Text('Test'),
|
||||
@@ -57,7 +57,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: MainBackgroundBouble(
|
||||
hasError: true,
|
||||
child: Text('Test'),
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: MainBackgroundBouble(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('Test'),
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
testWidgets('displays marketing bottom sheet', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
MarketingBottomSheet(),
|
||||
const MarketingBottomSheet(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
onPressed: () {
|
||||
showMarketingBottomSheet(context);
|
||||
},
|
||||
child: Text('Show'),
|
||||
child: const Text('Show'),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -11,50 +11,28 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: child,
|
||||
),
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
OptionWidget(
|
||||
option: null,
|
||||
duration: 7,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.byType(SizedBox), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with option', (tester) async {
|
||||
final option = PacketOptions(
|
||||
items: ['Item 1', 'Item 2'],
|
||||
price: 1000.0,
|
||||
short: 'Short',
|
||||
description: 'Description',
|
||||
hasPersonalDiet: false,
|
||||
);
|
||||
const option = PacketOptions(items: ['Item 1', 'Item 2'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
OptionWidget(
|
||||
option: option,
|
||||
duration: 7,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
expect(find.text('Short'), findsOneWidget);
|
||||
@@ -62,47 +40,19 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('displays option widget with personal diet', (tester) async {
|
||||
final option = PacketOptions(
|
||||
items: ['Item 1'],
|
||||
price: 1000.0,
|
||||
short: 'Short',
|
||||
description: 'Description',
|
||||
hasPersonalDiet: true,
|
||||
);
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
|
||||
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
OptionWidget(
|
||||
option: option,
|
||||
duration: 7,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('hides duration when disableDuration is true', (tester) async {
|
||||
final option = PacketOptions(
|
||||
items: ['Item 1'],
|
||||
price: 1000.0,
|
||||
short: 'Short',
|
||||
description: 'Description',
|
||||
hasPersonalDiet: false,
|
||||
);
|
||||
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
|
||||
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
OptionWidget(
|
||||
option: option,
|
||||
duration: 7,
|
||||
disableDuration: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
|
||||
|
||||
expect(find.byType(OptionWidget), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
testWidgets('displays error dialog with default title and description', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
onPressed: () {
|
||||
showErrorDialog(context);
|
||||
},
|
||||
child: Text('Show Error'),
|
||||
child: const Text('Show Error'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
testWidgets('displays error dialog with custom title and description', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -60,7 +60,7 @@ void main() {
|
||||
description: 'Custom Description',
|
||||
);
|
||||
},
|
||||
child: Text('Show Error'),
|
||||
child: const Text('Show Error'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
testWidgets('displays error dialog with custom button title', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -95,7 +95,7 @@ void main() {
|
||||
buttonTitle: 'Close',
|
||||
);
|
||||
},
|
||||
child: Text('Show Error'),
|
||||
child: const Text('Show Error'),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -112,7 +112,7 @@ void main() {
|
||||
testWidgets('closes dialog when button is tapped', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -126,7 +126,7 @@ void main() {
|
||||
onPressed: () {
|
||||
showErrorDialog(context);
|
||||
},
|
||||
child: Text('Show Error'),
|
||||
child: const Text('Show Error'),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
testWidgets('displays success published diet bottom sheet', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedDietOrPlanBottomSheet(
|
||||
const SuccessPublishedDietOrPlanBottomSheet(
|
||||
title: 'Test Diet',
|
||||
),
|
||||
),
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
testWidgets('displays diet published text when isPlan is false', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedDietOrPlanBottomSheet(
|
||||
const SuccessPublishedDietOrPlanBottomSheet(
|
||||
title: 'Test Diet',
|
||||
isPlan: false,
|
||||
),
|
||||
@@ -52,7 +52,7 @@ void main() {
|
||||
testWidgets('displays plan published text when isPlan is true', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedDietOrPlanBottomSheet(
|
||||
const SuccessPublishedDietOrPlanBottomSheet(
|
||||
title: 'Test Plan',
|
||||
isPlan: true,
|
||||
),
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
testWidgets('displays plan title', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedDietOrPlanBottomSheet(
|
||||
const SuccessPublishedDietOrPlanBottomSheet(
|
||||
title: 'My Plan',
|
||||
isPlan: true,
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
Widget createTestWidget(Widget child) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
testWidgets('displays success published recipe bottom sheet', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedRecipeBottomSheet(
|
||||
const SuccessPublishedRecipeBottomSheet(
|
||||
title: 'Test Recipe',
|
||||
),
|
||||
),
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
testWidgets('displays recipe title', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedRecipeBottomSheet(
|
||||
const SuccessPublishedRecipeBottomSheet(
|
||||
title: 'My Recipe',
|
||||
),
|
||||
),
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
testWidgets('has ok button', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
createTestWidget(
|
||||
SuccessPublishedRecipeBottomSheet(
|
||||
const SuccessPublishedRecipeBottomSheet(
|
||||
title: 'Test Recipe',
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user