Skip to content

Commit b5366af

Browse files
committed
format
1 parent 96d2418 commit b5366af

File tree

2 files changed

+46
-21
lines changed

2 files changed

+46
-21
lines changed

flutter_modular/lib/src/presenter/navigation/modular_route_information_parser.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import 'package:modular_core/modular_core.dart';
1313

1414
import 'modular_book.dart';
1515

16-
class ModularRouteInformationParser extends RouteInformationParser<ModularBook> {
16+
class ModularRouteInformationParser
17+
extends RouteInformationParser<ModularBook> {
1718
final GetRoute getRoute;
1819
final GetArguments getArguments;
1920
final SetArguments setArguments;
@@ -29,10 +30,12 @@ class ModularRouteInformationParser extends RouteInformationParser<ModularBook>
2930
});
3031

3132
@override
32-
Future<ModularBook> parseRouteInformation(RouteInformation routeInformation) async {
33+
Future<ModularBook> parseRouteInformation(
34+
RouteInformation routeInformation) async {
3335
var path = '';
3436
if (!_firstParse) {
35-
if (routeInformation.location == null || routeInformation.location == '/') {
37+
if (routeInformation.location == null ||
38+
routeInformation.location == '/') {
3639
// ignore: invalid_use_of_visible_for_testing_member
3740
path = initialRouteDeclaratedInMaterialApp;
3841
} else {
@@ -53,10 +56,12 @@ class ModularRouteInformationParser extends RouteInformationParser<ModularBook>
5356
return RouteInformation(location: book.uri.toString());
5457
}
5558

56-
Future<ModularBook> selectBook(String path, {dynamic arguments, void Function(dynamic)? popCallback}) async {
59+
Future<ModularBook> selectBook(String path,
60+
{dynamic arguments, void Function(dynamic)? popCallback}) async {
5761
var route = await selectRoute(path, arguments: arguments);
5862

59-
final modularArgs = getArguments().getOrElse((l) => ModularArguments.empty());
63+
final modularArgs =
64+
getArguments().getOrElse((l) => ModularArguments.empty());
6065
if (popCallback != null) {
6166
route = route.copyWith(popCallback: popCallback);
6267
}

flutter_modular/test/src/presenter/navigation/modular_route_information_parser_test.dart

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,24 @@ 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'))).thenReturn(routeMock);
82+
when(() => routeMock.copyWith(schema: any(named: 'schema')))
83+
.thenReturn(routeMock);
8384

8485
final routeParent = ParallelRouteMock();
8586
when(() => routeParent.uri).thenReturn(Uri.parse('/'));
8687
when(() => routeParent.parent).thenReturn('');
8788
when(() => routeParent.schema).thenReturn('');
8889
when(() => routeParent.middlewares).thenReturn([Guard()]);
89-
when(() => routeParent.copyWith(schema: any(named: 'schema'))).thenReturn(routeParent);
90+
when(() => routeParent.copyWith(schema: any(named: 'schema')))
91+
.thenReturn(routeParent);
9092

9193
when(() => reportPush(routeMock)).thenReturn(right(unit));
9294
when(() => reportPush(routeParent)).thenReturn(right(unit));
9395

94-
when(() => getRoute.call(RouteParmsDTO(url: '/test'))).thenAnswer((_) async => right(routeMock));
95-
when(() => getRoute.call(RouteParmsDTO(url: '/'))).thenAnswer((_) async => right(routeParent));
96+
when(() => getRoute.call(RouteParmsDTO(url: '/test')))
97+
.thenAnswer((_) async => right(routeMock));
98+
when(() => getRoute.call(RouteParmsDTO(url: '/')))
99+
.thenAnswer((_) async => right(routeParent));
96100
when(() => getArguments.call()).thenReturn(right(ModularArguments.empty()));
97101

98102
when(() => setArguments.call(any())).thenReturn(right(unit));
@@ -112,21 +116,26 @@ void main() {
112116
when(() => routeMock.parent).thenReturn('/');
113117
when(() => routeMock.schema).thenReturn('/');
114118
when(() => routeMock.middlewares).thenReturn([Guard()]);
115-
when(() => routeMock.copyWith(schema: any(named: 'schema'))).thenReturn(routeMock);
119+
when(() => routeMock.copyWith(schema: any(named: 'schema')))
120+
.thenReturn(routeMock);
116121

117122
final routeParent = ParallelRouteMock();
118123
when(() => routeParent.uri).thenReturn(Uri.parse('/'));
119124
when(() => routeParent.parent).thenReturn('');
120125
when(() => routeParent.schema).thenReturn('');
121126
when(() => routeParent.middlewares).thenReturn([Guard()]);
122-
when(() => routeParent.copyWith(schema: any(named: 'schema'))).thenReturn(routeParent);
127+
when(() => routeParent.copyWith(schema: any(named: 'schema')))
128+
.thenReturn(routeParent);
123129

124130
when(() => reportPush(routeMock)).thenReturn(right(unit));
125131
when(() => reportPush(routeParent)).thenReturn(right(unit));
126132

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));
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));
130139
when(() => getArguments.call()).thenReturn(right(args));
131140

132141
when(() => setArguments.call(any())).thenReturn(right(unit));
@@ -148,8 +157,10 @@ void main() {
148157

149158
when(() => reportPush(routeMock)).thenReturn(right(unit));
150159

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));
160+
when(() => getRoute.call(RouteParmsDTO(url: '/test', arguments: args)))
161+
.thenAnswer((_) async => left(ModularPageException('')));
162+
when(() => getRoute.call(RouteParmsDTO(url: '/test/', arguments: args)))
163+
.thenAnswer((_) async => right(routeMock));
153164
when(() => getArguments.call()).thenReturn(right(args));
154165

155166
when(() => setArguments.call(any())).thenReturn(right(unit));
@@ -176,8 +187,10 @@ void main() {
176187
when(() => getArguments.call()).thenReturn(right(ModularArguments.empty()));
177188
when(() => routeMock.middlewares).thenReturn([Guard()]);
178189

179-
expect(parser.parseRouteInformation(RouteInformation(location: '/test')), completion(isA<ModularBook>()));
180-
expect(parser.parseRouteInformation(RouteInformation(location: '/test')), completion(isA<ModularBook>()));
190+
expect(parser.parseRouteInformation(RouteInformation(location: '/test')),
191+
completion(isA<ModularBook>()));
192+
expect(parser.parseRouteInformation(RouteInformation(location: '/test')),
193+
completion(isA<ModularBook>()));
181194
expect(Guard().pre(routeMock), routeMock);
182195
});
183196

@@ -189,7 +202,10 @@ void main() {
189202
when(() => routeMock.middlewares).thenReturn([Guard(false)]);
190203
when(() => routeMock.uri).thenReturn(Uri.parse('/'));
191204

192-
expect(() async => await parser.parseRouteInformation(RouteInformation(location: '/')), throwsA(isA<GuardedRouteException>()));
205+
expect(
206+
() async =>
207+
await parser.parseRouteInformation(RouteInformation(location: '/')),
208+
throwsA(isA<GuardedRouteException>()));
193209
});
194210

195211
test('parseRouteInformation with location / and middleware null', () {
@@ -200,7 +216,10 @@ void main() {
200216
when(() => routeMock.middlewares).thenReturn([MiddlewareNull()]);
201217
when(() => routeMock.uri).thenReturn(Uri.parse('/'));
202218

203-
expect(() async => await parser.parseRouteInformation(RouteInformation(location: '/')), throwsA(isA<Exception>()));
219+
expect(
220+
() async =>
221+
await parser.parseRouteInformation(RouteInformation(location: '/')),
222+
throwsA(isA<Exception>()));
204223
});
205224

206225
test('throw error if path be empty', () {
@@ -215,7 +234,8 @@ void main() {
215234
when(() => routeMock.middlewares).thenReturn([]);
216235
when(() => routeMock.uri).thenReturn(Uri.parse('/'));
217236
when(() => routeMock.parent).thenReturn('');
218-
when(() => routeMock.copyWith(popCallback: any(named: 'popCallback'))).thenReturn(routeMock);
237+
when(() => routeMock.copyWith(popCallback: any(named: 'popCallback')))
238+
.thenReturn(routeMock);
219239
expect(parser.selectBook('/', popCallback: (r) {}), completes);
220240
});
221241
}

0 commit comments

Comments
 (0)