platform/packages/route/test/navigate_test.dart
Tobe O 5eef4314ec Add 'packages/route/' from commit '8b2b0524609ab737eb5569fdf82a7ac491fdc67b'
git-subtree-dir: packages/route
git-subtree-mainline: 6db839928b
git-subtree-split: 8b2b052460
2020-02-15 18:22:17 -05:00

44 lines
920 B
Dart

import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
main() {
final router = Router();
router.get('/', 'GET').name = 'root';
router.get('/user/:id', 'GET');
router.get('/first/:first/last/:last', 'GET').name = 'full_name';
navigate(params) {
final uri = router.navigate(params as Iterable);
print('Uri: $uri');
return uri;
}
router.dumpTree();
group('top-level', () {
test('named', () {
expect(navigate(['root']), equals('/'));
});
test('params', () {
expect(
navigate([
'user/:id',
{'id': 1337}
]),
equals('/user/1337'));
expect(
navigate([
'full_name',
{'first': 'John', 'last': 'Smith'}
]),
equals('/first/John/last/Smith'));
});
test('root', () {
expect(navigate(['/']), equals('/'));
});
});
}