Skip to content

Commit

Permalink
fix: change redirect route arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Spaki committed Jun 29, 2023
1 parent 575913f commit e4a7312
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,17 @@ class ModularRouteInformationParser
}

FutureOr<ParallelRoute> _routeSuccess(ModularRoute? route) async {
final arguments = getArguments().getOrElse((l) => ModularArguments.empty());
final modularArguments =
getArguments().getOrElse((l) => ModularArguments.empty());
for (var middleware in route!.middlewares) {
route = await middleware.pos(route!, arguments);
route = await middleware.pos(route!, modularArguments);
if (route == null) {
break;
}
}

if (route is RedirectRoute) {
route = await selectRoute(route.to, arguments: arguments);
route = await selectRoute(route.to, arguments: modularArguments.data);
}

if (route != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void main() {

test('selectRoute with RedirectRoute', () async {
final redirect = RedirectRoute('/oo', to: '/test');
final args = ModularArguments.empty();
final modularArgument = ModularArguments.empty();

final routeMock = ParallelRouteMock();
when(() => routeMock.uri).thenReturn(Uri.parse('/test'));
Expand All @@ -130,11 +130,12 @@ void main() {

when(() => getRoute.call(const RouteParmsDTO(url: '/oo')))
.thenAnswer((_) async => right(redirect));
when(() => getRoute.call(RouteParmsDTO(url: '/test', arguments: args)))
when(() => getRoute
.call(RouteParmsDTO(url: '/test', arguments: modularArgument.data)))
.thenAnswer((_) async => right(routeMock));
when(() => getRoute.call(const RouteParmsDTO(url: '/')))
.thenAnswer((_) async => right(routeParent));
when(() => getArguments.call()).thenReturn(right(args));
when(() => getArguments.call()).thenReturn(right(modularArgument));

when(() => setArguments.call(any())).thenReturn(right(unit));

Expand All @@ -143,7 +144,6 @@ void main() {
expect(book.chapters().first.name, '/');
expect(book.chapters('/').first.name, '/test');
});

test('selectRoute with resolver route withless /', () async {
final args = ModularArguments.empty();

Expand Down

0 comments on commit e4a7312

Please sign in to comment.