-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change widget tests for status alert widgets
- Loading branch information
Showing
2 changed files
with
122 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:status_alert/src/widgets/status_alert_base_widget.dart'; | ||
import 'package:status_alert/src/utils/status_allert_manager.dart'; | ||
import 'package:status_alert/status_alert.dart'; | ||
|
||
void main() { | ||
group('Status Alert Test', () { | ||
final statusAlert = StatusAlertBaseWidget( | ||
duration: Duration(minutes: 1), | ||
title: 'Subscribed', | ||
margin: const EdgeInsets.all(40.0), | ||
padding: EdgeInsets.zero, | ||
subtitle: 'test', | ||
alignment: Alignment.center, | ||
blurPower: 15, | ||
maxWidth: 260, | ||
titleOptions: StatusAlertTextConfiguration( | ||
style: TextStyle( | ||
color: Colors.red, | ||
fontSize: 23, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
subtitleOptions: StatusAlertTextConfiguration( | ||
style: TextStyle( | ||
color: Colors.orange, | ||
fontSize: 16, | ||
fontWeight: FontWeight.w400, | ||
), | ||
), | ||
borderRadius: const BorderRadius.all(Radius.circular(10.0)), | ||
onHide: StatusAlertManager.dismiss, | ||
configuration: IconConfiguration( | ||
icon: Icons.favorite_border, | ||
color: Colors.blue, | ||
), | ||
backgroundColor: Colors.green, | ||
); | ||
|
||
testWidgets('Widget should render correctly', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
expect(find.byType(StatusAlertBaseWidget), findsOneWidget); | ||
}); | ||
}); | ||
|
||
testWidgets('Title content should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
expect(find.text('Subscribed'), findsOneWidget); | ||
}); | ||
}); | ||
|
||
testWidgets('Title style should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
final titleWidget = tester.widget<Text>(find.text('Subscribed')); | ||
|
||
expect(titleWidget.style?.color, Colors.red); | ||
expect(titleWidget.style?.fontSize, 23); | ||
expect(titleWidget.style?.fontWeight, FontWeight.w600); | ||
}); | ||
}); | ||
|
||
testWidgets('SubTitle content should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
expect(find.text('test'), findsOneWidget); | ||
}); | ||
}); | ||
|
||
testWidgets('SubTitle style should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
final titleWidget = tester.widget<Text>(find.text('test')); | ||
|
||
expect(titleWidget.style?.color, Colors.orange); | ||
expect(titleWidget.style?.fontSize, 16); | ||
expect(titleWidget.style?.fontWeight, FontWeight.w400); | ||
}); | ||
}); | ||
|
||
testWidgets('Widget color should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
final statusAlertWidget = tester | ||
.widget<StatusAlertBaseWidget>(find.byType(StatusAlertBaseWidget)); | ||
|
||
expect(statusAlertWidget.backgroundColor, Colors.green); | ||
}); | ||
}); | ||
|
||
testWidgets('Icon content should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
|
||
expect(find.byIcon(Icons.favorite_border), findsOneWidget); | ||
}); | ||
}); | ||
|
||
testWidgets('Icon colour should match', (tester) async { | ||
await tester.runAsync(() async { | ||
await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); | ||
final iconWidget = | ||
tester.widget<Icon>(find.byIcon(Icons.favorite_border)); | ||
|
||
expect(iconWidget.color, Colors.blue); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
Widget _wrapWithMaterialApp(Widget testWidget) { | ||
return MaterialApp(home: testWidget); | ||
} |