@@ -13,6 +13,24 @@ void main() {
1313 final bodyFinder = find.text ('Test Body' );
1414 final footerFinder = find.text ('Test Footer' );
1515
16+ // Helper function to create the IntroPage widget
17+ Widget createIntroPage (
18+ {bool isFullScreen = false ,
19+ PageDecoration ? pageDecoration,
20+ bool useScrollView = true ,
21+ Widget ? image}) {
22+ return IntroPage (
23+ page: PageViewModel (
24+ title: 'Test Title' ,
25+ body: 'Test Body' ,
26+ image: image,
27+ footer: const Text ('Test Footer' ),
28+ decoration: pageDecoration ?? const PageDecoration (),
29+ useScrollView: useScrollView,
30+ ),
31+ );
32+ }
33+
1634 testWidgets ('IntroButton has text' , (tester) async {
1735 await tester.pumpWidget (testableWidget (
1836 child: IntroButton (child: const Text ('Test Text' )),
@@ -61,17 +79,13 @@ void main() {
6179
6280 testWidgets ('renders IntroPage with full screen stack' ,
6381 (WidgetTester tester) async {
64- await tester.pumpWidget (testableWidget (
65- child: IntroPage (
66- page: PageViewModel (
67- title: 'Test Title' ,
68- body: 'Test Body' ,
69- footer: const Text ('Test Footer' ),
70- decoration: PageDecoration (fullScreen: true ),
71- // useScrollView: false,
82+ await tester.pumpWidget (
83+ testableWidget (
84+ child: createIntroPage (
85+ pageDecoration: PageDecoration (fullScreen: true ),
7286 ),
7387 ),
74- )) ;
88+ );
7589
7690 // Check that the IntroContent is rendered in a Stack
7791 expect (find.byType (Stack ), findsWidgets);
@@ -82,16 +96,8 @@ void main() {
8296
8397 testWidgets ('renders IntroPage with Flex layout' ,
8498 (WidgetTester tester) async {
85- await tester.pumpWidget (testableWidget (
86- child: IntroPage (
87- page: PageViewModel (
88- title: 'Test Title' ,
89- body: 'Test Body' ,
90- footer: const Text ('Test Footer' ),
91- useScrollView: false ,
92- ),
93- ),
94- ));
99+ await tester.pumpWidget (
100+ testableWidget (child: createIntroPage (useScrollView: false )));
95101
96102 // Check that the IntroContent is rendered in a Flex layout
97103 expect (find.byType (Flex ), findsOneWidget);
@@ -110,14 +116,9 @@ void main() {
110116 );
111117
112118 await tester.pumpWidget (testableWidget (
113- child: IntroPage (
114- page: PageViewModel (
115- title: 'Test Title' ,
116- body: 'Test Body' ,
117- image: mockImage, // Set the page image to the mock image
118- footer: const Text ('Test Footer' ),
119- useScrollView: false ,
120- ),
119+ child: createIntroPage (
120+ useScrollView: false ,
121+ image: mockImage, // Set the page image to the mock image
121122 ),
122123 ));
123124
0 commit comments