refactor(tests): replace 'final' with 'const' for improved performance in various test files

This commit is contained in:
mso7nueh
2025-12-08 11:32:40 +03:00
parent c2a506cdbf
commit 746d366c18
56 changed files with 199 additions and 254 deletions

View File

@@ -24,7 +24,7 @@ void main() {
theme: ThemeHelper().themeData(),
home: BlocProvider<DiaryCubit>.value(
value: mockCubit,
child: Scaffold(
child: const Scaffold(
body: AddProductButtonWidget(),
),
),
@@ -32,7 +32,7 @@ void main() {
}
testWidgets('displays add product button widget', (tester) async {
final loadingState = DiaryState.loading();
const loadingState = DiaryState.loading();
when(mockCubit.state).thenReturn(loadingState);
when(mockCubit.stream).thenAnswer((_) => Stream.value(loadingState));

View File

@@ -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 chosen diet widget content', (tester) async {
await tester.pumpWidget(
createTestWidget(
ChosenDietWidgetContent(
const ChosenDietWidgetContent(
currentDietDay: 5,
dietName: 'Test Diet',
dietDuration: 14,
@@ -42,7 +42,7 @@ void main() {
testWidgets('displays current day and duration', (tester) async {
await tester.pumpWidget(
createTestWidget(
ChosenDietWidgetContent(
const ChosenDietWidgetContent(
currentDietDay: 7,
dietName: 'Test Diet',
dietDuration: 21,
@@ -57,7 +57,7 @@ void main() {
testWidgets('displays diet name with underline', (tester) async {
await tester.pumpWidget(
createTestWidget(
ChosenDietWidgetContent(
const ChosenDietWidgetContent(
currentDietDay: 1,
dietName: 'My Diet',
dietDuration: 7,

View File

@@ -9,7 +9,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
home: const Scaffold(
body: CommentContainer(comment: 'Test comment'),
),
),
@@ -23,7 +23,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
home: const Scaffold(
body: CommentContainer(comment: ''),
),
),
@@ -37,7 +37,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
home: const Scaffold(
body: CommentContainer(comment: longComment),
),
),

View File

@@ -7,7 +7,7 @@ void main() {
group('ProductLoaderWidget', () {
testWidgets('displays product loader widget', (tester) async {
await tester.pumpWidget(
MaterialApp(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),
@@ -20,7 +20,7 @@ void main() {
testWidgets('displays ListTile with activity indicator', (tester) async {
await tester.pumpWidget(
MaterialApp(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),