platform/test/navigate_test.dart

45 lines
912 B
Dart
Raw Normal View History

2016-11-25 23:22:33 +00:00
import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
main() {
final router = new Router();
2017-11-27 02:21:19 +00:00
router.get('/', 'GET').name = 'root';
2016-11-25 23:22:33 +00:00
router.get('/user/:id', 'GET');
2017-11-27 02:21:19 +00:00
router.get('/first/:first/last/:last', 'GET').name = 'full_name';
2016-11-25 23:22:33 +00:00
navigate(params) {
final uri = router.navigate(params);
print('Uri: $uri');
return uri;
}
2017-11-27 02:21:19 +00:00
router.dumpTree();
2016-11-25 23:22:33 +00:00
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('/'));
});
});
}