Skip to content

Commit

Permalink
add unitTest for ignoreRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhaintz committed Aug 7, 2024
1 parent 22833ce commit 9675412
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,25 @@ void main() {
observer.didReplace(newRoute: route(to), oldRoute: route(previous));
expect(hub.scope.transaction, 'to_test');
});

test('ignores Route and prevents recognition of this route', () async {
final firstRoute = route(RouteSettings(name: 'default'));
final secondRoute = route(RouteSettings(name: 'testRoute'));

final hub = _MockHub();

final sut = fixture.getSut(hub: hub, ignoreRoutes: ["testRoute"]);

sut.didPush(firstRoute, null);
expect(
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
sut.didPush(secondRoute, firstRoute);
expect(
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
sut.didPop(firstRoute, secondRoute);
expect(
SentryNavigatorObserver.currentRouteName, firstRoute.settings.name);
});
});
}

Expand All @@ -987,6 +1006,7 @@ class Fixture {
RouteNameExtractor? routeNameExtractor,
AdditionalInfoExtractor? additionalInfoProvider,
bool enableTimeToFullDisplayTracing = false,
List<String>? ignoreRoutes,
}) {
final frameCallbackHandler = FakeFrameCallbackHandler();
final timeToInitialDisplayTracker =
Expand All @@ -1003,6 +1023,7 @@ class Fixture {
routeNameExtractor: routeNameExtractor,
additionalInfoProvider: additionalInfoProvider,
timeToDisplayTracker: timeToDisplayTracker,
ignoreRoutes: ignoreRoutes,
);
}

Expand Down

0 comments on commit 9675412

Please sign in to comment.