@@ -37,10 +37,7 @@ void main() {
3737 bool fullscreenDialog = false ,
3838 }) {
3939 return MaterialPageRoute <T >(
40- settings: RouteSettings (
41- name: name,
42- arguments: arguments,
43- ),
40+ settings: RouteSettings (name: name, arguments: arguments),
4441 maintainState: maintainState,
4542 fullscreenDialog: fullscreenDialog,
4643 builder: (_) => const SizedBox (),
@@ -49,19 +46,17 @@ void main() {
4946
5047 group ('constructor' , () {
5148 test (
52- 'throws AssertionError when both whereSettings '
53- 'and whereName or whereArguments matchers are provided' ,
54- () {
55- expect (
56- () => isRoute (
57- whereSettings: isNotNull,
58- whereName: isNotNull,
59- whereArguments: isNotNull,
60- ),
61- throwsAssertionError,
62- );
63- },
64- );
49+ 'throws AssertionError when both whereSettings '
50+ 'and whereName or whereArguments matchers are provided' , () {
51+ expect (
52+ () => isRoute (
53+ whereSettings: isNotNull,
54+ whereName: isNotNull,
55+ whereArguments: isNotNull,
56+ ),
57+ throwsAssertionError,
58+ );
59+ });
6560 });
6661
6762 group ('without arguments' , () {
@@ -130,43 +125,44 @@ void main() {
130125 expect (
131126 createRoute <dynamic >(name: '/test' ),
132127 isRoute (
133- whereSettings:
134- isA <RouteSettings >().having ((s) => s.name, 'name' , '/test' ),
128+ whereSettings: isA <RouteSettings >().having (
129+ (s) => s.name,
130+ 'name' ,
131+ '/test' ,
132+ ),
135133 ),
136134 );
137135 });
138136
139137 test (
140- 'does not match anything that is not a route '
141- 'with matching settings' ,
142- () {
143- expectToFail (
144- createRoute <dynamic >(name: '/test' ),
145- isRoute (whereSettings: equalsSettingsOf (createRoute <String >())),
146- withMessage:
147- "is a route where `settings` has `name` with value '/test'" ,
148- );
149- expectToFail (
150- createRoute <dynamic >(name: '/other_name' ),
151- isRoute (
152- whereSettings: equalsSettingsOf (
153- createRoute <dynamic >(name: '/test' ),
154- ),
138+ 'does not match anything that is not a route '
139+ 'with matching settings' , () {
140+ expectToFail (
141+ createRoute <dynamic >(name: '/test' ),
142+ isRoute (whereSettings: equalsSettingsOf (createRoute <String >())),
143+ withMessage:
144+ "is a route where `settings` has `name` with value '/test'" ,
145+ );
146+ expectToFail (
147+ createRoute <dynamic >(name: '/other_name' ),
148+ isRoute (
149+ whereSettings: equalsSettingsOf (
150+ createRoute <dynamic >(name: '/test' ),
155151 ),
156- withMessage: '''
152+ ),
153+ withMessage: '''
157154is a route where `settings` has `name` with value '/other_name' which is different.
158155 Expected: /test
159156 Actual: /other_name ...
160157 ^
161158 Differ at offset 1''' ,
162- );
163- expectToFail (
164- 1 ,
165- isRoute (whereSettings: equalsSettingsOf (createRoute <dynamic >())),
166- withMessage: 'is not a route but an instance of `int`' ,
167- );
168- },
169- );
159+ );
160+ expectToFail (
161+ 1 ,
162+ isRoute (whereSettings: equalsSettingsOf (createRoute <dynamic >())),
163+ withMessage: 'is not a route but an instance of `int`' ,
164+ );
165+ });
170166 });
171167
172168 group ('with whereName argument' , () {
@@ -244,36 +240,31 @@ is a route where the route's `name` is different.
244240
245241 group ('with whereMaintainState argument' , () {
246242 test ('matches any route with matching maintainState argument' , () {
247- expect (
243+ expect (createRoute <dynamic >(), isRoute (whereMaintainState: isTrue));
244+ });
245+
246+ test (
247+ 'does not match anything that is not a route with matching '
248+ 'maintainState argument' , () {
249+ expectToFail (
248250 createRoute <dynamic >(),
251+ isRoute (whereMaintainState: isFalse),
252+ withMessage: 'is a route where `maintainState` '
253+ 'is true instead of false' ,
254+ );
255+ expectToFail (
256+ NonModalRoute (),
249257 isRoute (whereMaintainState: isTrue),
258+ withMessage: 'is a route where `maintainState` '
259+ 'is not a property on `NonModalRoute` and can only be used '
260+ 'with `ModalRoute`s' ,
261+ );
262+ expectToFail (
263+ 1 ,
264+ isRoute (whereMaintainState: isTrue),
265+ withMessage: 'is not a route but an instance of `int`' ,
250266 );
251267 });
252-
253- test (
254- 'does not match anything that is not a route with matching '
255- 'maintainState argument' ,
256- () {
257- expectToFail (
258- createRoute <dynamic >(),
259- isRoute (whereMaintainState: isFalse),
260- withMessage: 'is a route where `maintainState` '
261- 'is true instead of false' ,
262- );
263- expectToFail (
264- NonModalRoute (),
265- isRoute (whereMaintainState: isTrue),
266- withMessage: 'is a route where `maintainState` '
267- 'is not a property on `NonModalRoute` and can only be used '
268- 'with `ModalRoute`s' ,
269- );
270- expectToFail (
271- 1 ,
272- isRoute (whereMaintainState: isTrue),
273- withMessage: 'is not a route but an instance of `int`' ,
274- );
275- },
276- );
277268 });
278269
279270 group ('with whereFullscreenDialog argument' , () {
@@ -285,29 +276,27 @@ is a route where the route's `name` is different.
285276 });
286277
287278 test (
288- 'does not match anything that is not a route with matching '
289- 'fullscreenDialog argument' ,
290- () {
291- expectToFail (
292- createRoute <dynamic >(fullscreenDialog: true ),
293- isRoute (whereFullscreenDialog: isFalse),
294- withMessage: 'is a route where `fullscreenDialog` '
295- 'is true instead of false' ,
296- );
297- expectToFail (
298- NonModalRoute (),
299- isRoute (whereFullscreenDialog: isFalse),
300- withMessage: 'is a route where `fullscreenDialog` '
301- 'is not a property on `NonModalRoute` and can only be used '
302- 'with `PageRoute`s' ,
303- );
304- expectToFail (
305- 1 ,
306- isRoute (whereFullscreenDialog: isTrue),
307- withMessage: 'is not a route but an instance of `int`' ,
308- );
309- },
310- );
279+ 'does not match anything that is not a route with matching '
280+ 'fullscreenDialog argument' , () {
281+ expectToFail (
282+ createRoute <dynamic >(fullscreenDialog: true ),
283+ isRoute (whereFullscreenDialog: isFalse),
284+ withMessage: 'is a route where `fullscreenDialog` '
285+ 'is true instead of false' ,
286+ );
287+ expectToFail (
288+ NonModalRoute (),
289+ isRoute (whereFullscreenDialog: isFalse),
290+ withMessage: 'is a route where `fullscreenDialog` '
291+ 'is not a property on `NonModalRoute` and can only be used '
292+ 'with `PageRoute`s' ,
293+ );
294+ expectToFail (
295+ 1 ,
296+ isRoute (whereFullscreenDialog: isTrue),
297+ withMessage: 'is not a route but an instance of `int`' ,
298+ );
299+ });
311300 });
312301
313302 test ('returns all relevant mismatches in one log' , () {
0 commit comments