Skip to content

Commit bbb8757

Browse files
committed
content test [nfc]: Have prepareContentBare give pointer to pushed routes
1 parent 2a19f95 commit bbb8757

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/widgets/content_test.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void main() {
9292

9393
TestZulipBinding.ensureInitialized();
9494

95-
Future<void> prepareContentBare(WidgetTester tester, String html, {
95+
Future<List<Route<dynamic>>> prepareContentBare(WidgetTester tester, String html, {
9696
bool wrapWithScaffold = false,
9797
bool wrapWithPerAccountStoreWidget = false,
9898
}) async {
@@ -110,17 +110,28 @@ void main() {
110110
widget = GlobalStoreWidget(child: widget);
111111
addTearDown(testBinding.reset);
112112

113+
final pushedRoutes = <Route<dynamic>>[];
114+
final testNavObserver = TestNavigatorObserver()
115+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
116+
113117
await tester.pumpWidget(
114118
Builder(builder: (context) =>
115119
MaterialApp(
116120
theme: ThemeData(typography: zulipTypography(context)),
117121
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
118122
supportedLocales: ZulipLocalizations.supportedLocales,
123+
navigatorObservers: [testNavObserver],
119124
home: widget)));
120125
await tester.pump(); // global store
121126
if (wrapWithPerAccountStoreWidget) {
122127
await tester.pump();
123128
}
129+
130+
// `tester.pumpWidget` introduces an initial route;
131+
// remove it so consumers only have newly pushed routes.
132+
assert(pushedRoutes.length == 1);
133+
pushedRoutes.removeLast();
134+
return pushedRoutes;
124135
}
125136

126137
/// Test that the given content example renders without throwing an exception.

0 commit comments

Comments
 (0)