Skip to content

Commit f83c795

Browse files
committed
app test [nfc]: Convert initialRoutes into a generic helper
Signed-off-by: Zixuan James Li <[email protected]>
1 parent af76dc8 commit f83c795

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/widgets/app_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ void main() {
2424
group('ZulipApp initial navigation', () {
2525
late List<Route<dynamic>> pushedRoutes = [];
2626

27-
Future<List<Route<dynamic>>> initialRoutes(WidgetTester tester) async {
27+
Future<void> prepare(WidgetTester tester) async {
28+
addTearDown(testBinding.reset);
29+
2830
pushedRoutes = [];
2931
final testNavObserver = TestNavigatorObserver()
3032
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
3133
await tester.pumpWidget(ZulipApp(navigatorObservers: [testNavObserver]));
3234
await tester.pump();
33-
return pushedRoutes;
3435
}
3536

3637
testWidgets('when no accounts, go to choose account', (tester) async {
37-
addTearDown(testBinding.reset);
38-
check(await initialRoutes(tester)).deepEquals(<Condition<Object?>>[
38+
await prepare(tester);
39+
check(pushedRoutes).deepEquals(<Condition<Object?>>[
3940
(it) => it.isA<WidgetRoute>().page.isA<ChooseAccountPage>(),
4041
]);
4142
});
4243

4344
testWidgets('when have accounts, go to inbox for first account', (tester) async {
44-
addTearDown(testBinding.reset);
45-
4645
// We'll need per-account data for the account that a page will be opened
4746
// for, but not for the other account.
4847
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
4948
await testBinding.globalStore.insertAccount(eg.otherAccount.toCompanion(false));
49+
await prepare(tester);
5050

51-
check(await initialRoutes(tester)).deepEquals(<Condition<Object?>>[
51+
check(pushedRoutes).deepEquals(<Condition<Object?>>[
5252
(it) => it.isA<WidgetRoute>().page.isA<ChooseAccountPage>(),
5353
(it) => it.isA<MaterialAccountWidgetRoute>()
5454
..accountId.equals(eg.selfAccount.id)

0 commit comments

Comments
 (0)