Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
testing tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
csells committed Nov 3, 2021
1 parent b3f7568 commit c2b4944
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
10 changes: 5 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
104 changes: 52 additions & 52 deletions test/go_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c2b4944

Please sign in to comment.