Skip to content

Commit 280500c

Browse files
committed
test: add default behavior test when index is changed
1 parent 652f686 commit 280500c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/lazy_load_indexed_stack_test.dart

+25
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,38 @@ void main() {
1919
],
2020
);
2121

22+
// initial state index = 0
2223
await tester.pumpWidget(MaterialApp(home: lazyLoadIndexedStack));
2324

2425
expect(find.text('page1', skipOffstage: false), findsOneWidget);
2526
expect(find.text('page2', skipOffstage: false), findsNothing);
2627
expect(find.text('page3', skipOffstage: false), findsNothing);
2728
expect(find.text('page4', skipOffstage: false), findsNothing);
2829
expect(find.text('page5', skipOffstage: false), findsNothing);
30+
31+
// switch to index = 2
32+
await tester.pumpWidget(
33+
MaterialApp(
34+
home: LazyLoadIndexedStack(
35+
key: key,
36+
index: 2,
37+
children: [
38+
_buildWidget(1),
39+
_buildWidget(2),
40+
_buildWidget(3),
41+
_buildWidget(4),
42+
_buildWidget(5),
43+
],
44+
),
45+
),
46+
);
47+
await tester.pump();
48+
49+
expect(find.text('page1', skipOffstage: false), findsOneWidget);
50+
expect(find.text('page2', skipOffstage: false), findsNothing);
51+
expect(find.text('page3', skipOffstage: false), findsOneWidget);
52+
expect(find.text('page4', skipOffstage: false), findsNothing);
53+
expect(find.text('page5', skipOffstage: false), findsNothing);
2954
});
3055
});
3156

0 commit comments

Comments
 (0)