@@ -79,24 +79,20 @@ void main() {
7979 when (() => routeMock.parent).thenReturn ('/' );
8080 when (() => routeMock.schema).thenReturn ('/' );
8181 when (() => routeMock.middlewares).thenReturn ([Guard ()]);
82- when (() => routeMock.copyWith (schema: any (named: 'schema' )))
83- .thenReturn (routeMock);
82+ when (() => routeMock.copyWith (schema: any (named: 'schema' ))).thenReturn (routeMock);
8483
8584 final routeParent = ParallelRouteMock ();
8685 when (() => routeParent.uri).thenReturn (Uri .parse ('/' ));
8786 when (() => routeParent.parent).thenReturn ('' );
8887 when (() => routeParent.schema).thenReturn ('' );
8988 when (() => routeParent.middlewares).thenReturn ([Guard ()]);
90- when (() => routeParent.copyWith (schema: any (named: 'schema' )))
91- .thenReturn (routeParent);
89+ when (() => routeParent.copyWith (schema: any (named: 'schema' ))).thenReturn (routeParent);
9290
9391 when (() => reportPush (routeMock)).thenReturn (right (unit));
9492 when (() => reportPush (routeParent)).thenReturn (right (unit));
9593
96- when (() => getRoute.call (RouteParmsDTO (url: '/test' )))
97- .thenAnswer ((_) async => right (routeMock));
98- when (() => getRoute.call (RouteParmsDTO (url: '/' )))
99- .thenAnswer ((_) async => right (routeParent));
94+ when (() => getRoute.call (RouteParmsDTO (url: '/test' ))).thenAnswer ((_) async => right (routeMock));
95+ when (() => getRoute.call (RouteParmsDTO (url: '/' ))).thenAnswer ((_) async => right (routeParent));
10096 when (() => getArguments.call ()).thenReturn (right (ModularArguments .empty ()));
10197
10298 when (() => setArguments.call (any ())).thenReturn (right (unit));
@@ -116,26 +112,21 @@ void main() {
116112 when (() => routeMock.parent).thenReturn ('/' );
117113 when (() => routeMock.schema).thenReturn ('/' );
118114 when (() => routeMock.middlewares).thenReturn ([Guard ()]);
119- when (() => routeMock.copyWith (schema: any (named: 'schema' )))
120- .thenReturn (routeMock);
115+ when (() => routeMock.copyWith (schema: any (named: 'schema' ))).thenReturn (routeMock);
121116
122117 final routeParent = ParallelRouteMock ();
123118 when (() => routeParent.uri).thenReturn (Uri .parse ('/' ));
124119 when (() => routeParent.parent).thenReturn ('' );
125120 when (() => routeParent.schema).thenReturn ('' );
126121 when (() => routeParent.middlewares).thenReturn ([Guard ()]);
127- when (() => routeParent.copyWith (schema: any (named: 'schema' )))
128- .thenReturn (routeParent);
122+ when (() => routeParent.copyWith (schema: any (named: 'schema' ))).thenReturn (routeParent);
129123
130124 when (() => reportPush (routeMock)).thenReturn (right (unit));
131125 when (() => reportPush (routeParent)).thenReturn (right (unit));
132126
133- when (() => getRoute.call (RouteParmsDTO (url: '/oo' )))
134- .thenAnswer ((_) async => right (redirect));
135- when (() => getRoute.call (RouteParmsDTO (url: '/test' , arguments: args)))
136- .thenAnswer ((_) async => right (routeMock));
137- when (() => getRoute.call (RouteParmsDTO (url: '/' )))
138- .thenAnswer ((_) async => right (routeParent));
127+ when (() => getRoute.call (RouteParmsDTO (url: '/oo' ))).thenAnswer ((_) async => right (redirect));
128+ when (() => getRoute.call (RouteParmsDTO (url: '/test' , arguments: args))).thenAnswer ((_) async => right (routeMock));
129+ when (() => getRoute.call (RouteParmsDTO (url: '/' ))).thenAnswer ((_) async => right (routeParent));
139130 when (() => getArguments.call ()).thenReturn (right (args));
140131
141132 when (() => setArguments.call (any ())).thenReturn (right (unit));
@@ -146,6 +137,27 @@ void main() {
146137 expect (book.chapters ('/' ).first.name, '/test' );
147138 });
148139
140+ test ('selectRoute with resolver route withless /' , () async {
141+ final args = ModularArguments .empty ();
142+
143+ final routeMock = ParallelRouteMock ();
144+ when (() => routeMock.uri).thenReturn (Uri .parse ('/test/' ));
145+ when (() => routeMock.parent).thenReturn ('' );
146+ when (() => routeMock.schema).thenReturn ('' );
147+ when (() => routeMock.middlewares).thenReturn ([]);
148+
149+ when (() => reportPush (routeMock)).thenReturn (right (unit));
150+
151+ when (() => getRoute.call (RouteParmsDTO (url: '/test' , arguments: args))).thenAnswer ((_) async => left (ModularPageException ('' )));
152+ when (() => getRoute.call (RouteParmsDTO (url: '/test/' , arguments: args))).thenAnswer ((_) async => right (routeMock));
153+ when (() => getArguments.call ()).thenReturn (right (args));
154+
155+ when (() => setArguments.call (any ())).thenReturn (right (unit));
156+
157+ final route = await parser.selectRoute ('/test' , arguments: args);
158+ expect (route.uri.toString (), '/test/' );
159+ });
160+
149161 test ('restoreRouteInformation' , () {
150162 final route = ParallelRouteMock ();
151163 when (() => route.uri).thenReturn (Uri .parse ('/test' ));
@@ -164,10 +176,8 @@ void main() {
164176 when (() => getArguments.call ()).thenReturn (right (ModularArguments .empty ()));
165177 when (() => routeMock.middlewares).thenReturn ([Guard ()]);
166178
167- expect (parser.parseRouteInformation (RouteInformation (location: '/test' )),
168- completion (isA <ModularBook >()));
169- expect (parser.parseRouteInformation (RouteInformation (location: '/test' )),
170- completion (isA <ModularBook >()));
179+ expect (parser.parseRouteInformation (RouteInformation (location: '/test' )), completion (isA <ModularBook >()));
180+ expect (parser.parseRouteInformation (RouteInformation (location: '/test' )), completion (isA <ModularBook >()));
171181 expect (Guard ().pre (routeMock), routeMock);
172182 });
173183
@@ -179,10 +189,7 @@ void main() {
179189 when (() => routeMock.middlewares).thenReturn ([Guard (false )]);
180190 when (() => routeMock.uri).thenReturn (Uri .parse ('/' ));
181191
182- expect (
183- () async =>
184- await parser.parseRouteInformation (RouteInformation (location: '/' )),
185- throwsA (isA <GuardedRouteException >()));
192+ expect (() async => await parser.parseRouteInformation (RouteInformation (location: '/' )), throwsA (isA <GuardedRouteException >()));
186193 });
187194
188195 test ('parseRouteInformation with location / and middleware null' , () {
@@ -193,10 +200,7 @@ void main() {
193200 when (() => routeMock.middlewares).thenReturn ([MiddlewareNull ()]);
194201 when (() => routeMock.uri).thenReturn (Uri .parse ('/' ));
195202
196- expect (
197- () async =>
198- await parser.parseRouteInformation (RouteInformation (location: '/' )),
199- throwsA (isA <Exception >()));
203+ expect (() async => await parser.parseRouteInformation (RouteInformation (location: '/' )), throwsA (isA <Exception >()));
200204 });
201205
202206 test ('throw error if path be empty' , () {
@@ -211,8 +215,7 @@ void main() {
211215 when (() => routeMock.middlewares).thenReturn ([]);
212216 when (() => routeMock.uri).thenReturn (Uri .parse ('/' ));
213217 when (() => routeMock.parent).thenReturn ('' );
214- when (() => routeMock.copyWith (popCallback: any (named: 'popCallback' )))
215- .thenReturn (routeMock);
218+ when (() => routeMock.copyWith (popCallback: any (named: 'popCallback' ))).thenReturn (routeMock);
216219 expect (parser.selectBook ('/' , popCallback: (r) {}), completes);
217220 });
218221}
0 commit comments