diff --git a/pubspec.lock b/pubspec.lock index eed8285d..4ac39c88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,7 +14,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -85,7 +85,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: @@ -153,7 +153,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" typed_data: dependency: transitive description: @@ -167,7 +167,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" sdks: dart: ">=2.14.0 <3.0.0" flutter: ">=1.17.0" diff --git a/test/go_router_test.dart b/test/go_router_test.dart index 8397626f..89414e9f 100644 --- a/test/go_router_test.dart +++ b/test/go_router_test.dart @@ -367,58 +367,6 @@ void main() { expect(matches.length, 1); expect(router.pageFor(matches[0]).runtimeType, ErrorPage); }); - - test('preserve inline param case', () { - final routes = [ - GoRoute( - path: '/', - pageBuilder: (builder, state) => HomePage(), - ), - GoRoute( - path: '/family/:fid', - pageBuilder: (builder, state) => FamilyPage(state.params['fid']!), - ), - ]; - - final router = _router(routes); - for (final fid in ['f2', 'F2']) { - final loc = '/family/$fid'; - router.go(loc); - final matches = router.routerDelegate.matches; - - expect(router.location, loc); - expect(matches.length, 1); - expect(router.pageFor(matches[0]).runtimeType, FamilyPage); - expect(matches[0].params['fid'], fid); - } - }); - - test('preserve query param case', () { - final routes = [ - GoRoute( - path: '/', - pageBuilder: (builder, state) => HomePage(), - ), - GoRoute( - path: '/family', - pageBuilder: (builder, state) => FamilyPage( - state.queryParams['fid']!, - ), - ), - ]; - - final router = _router(routes); - for (final fid in ['f2', 'F2']) { - final loc = '/family?fid=$fid'; - router.go(loc); - final matches = router.routerDelegate.matches; - - expect(router.location, loc); - expect(matches.length, 1); - expect(router.pageFor(matches[0]).runtimeType, FamilyPage); - expect(matches[0].queryParams['fid'], fid); - } - }); }); group('named routes', () { @@ -1037,6 +985,58 @@ void main() { }); group('params', () { + test('preserve path param case', () { + final routes = [ + GoRoute( + path: '/', + pageBuilder: (builder, state) => HomePage(), + ), + GoRoute( + path: '/family/:fid', + pageBuilder: (builder, state) => FamilyPage(state.params['fid']!), + ), + ]; + + final router = _router(routes); + for (final fid in ['f2', 'F2']) { + final loc = '/family/$fid'; + router.go(loc); + final matches = router.routerDelegate.matches; + + expect(router.location, loc); + expect(matches.length, 1); + expect(router.pageFor(matches[0]).runtimeType, FamilyPage); + expect(matches[0].params['fid'], fid); + } + }); + + test('preserve query param case', () { + final routes = [ + GoRoute( + path: '/', + pageBuilder: (builder, state) => HomePage(), + ), + GoRoute( + path: '/family', + pageBuilder: (builder, state) => FamilyPage( + state.queryParams['fid']!, + ), + ), + ]; + + final router = _router(routes); + for (final fid in ['f2', 'F2']) { + final loc = '/family?fid=$fid'; + router.go(loc); + final matches = router.routerDelegate.matches; + + expect(router.location, loc); + expect(matches.length, 1); + expect(router.pageFor(matches[0]).runtimeType, FamilyPage); + expect(matches[0].queryParams['fid'], fid); + } + }); + test('error: duplicate path param', () { try { GoRouter(