Skip to content

Commit 62c0e9e

Browse files
authored
feat: support removeRouteBelow method (#90)
1 parent a147b63 commit 62c0e9e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/src/mock_navigator.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,9 @@ class _MockNavigatorState extends NavigatorState {
332332
arguments: arguments,
333333
);
334334
}
335+
336+
@override
337+
void removeRouteBelow(Route<dynamic> anchorRoute) {
338+
return _navigator.removeRouteBelow(anchorRoute);
339+
}
335340
}

test/src/mock_navigator_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,21 @@ void main() {
453453
),
454454
).called(1);
455455
});
456+
457+
testWidgets('mocks .removeRouteBelow calls', (tester) async {
458+
when(() => navigator.removeRouteBelow(any())).thenAnswer((_) {});
459+
460+
await tester.pumpTest(
461+
navigator: navigator,
462+
builder: (context) => TextButton(
463+
onPressed: () => Navigator.of(context).removeRouteBelow(testRoute),
464+
child: const Text('Trigger'),
465+
),
466+
);
467+
468+
await tester.tap(find.byType(TextButton));
469+
470+
verify(() => navigator.removeRouteBelow(testRoute)).called(1);
471+
});
456472
});
457473
}

0 commit comments

Comments
 (0)