platform/packages/route/test/parse_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

20 lines
479 B
Dart

import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
void main() {
var router = Router()
..get('/int/int:id', '')
..get('/double/double:id', '')
..get('/num/num:id', '');
num getId(String path) {
var result = router.resolveAbsolute(path).first;
return result.allParams['id'] as num;
}
test('parse', () {
expect(getId('/int/2'), 2);
expect(getId('/double/2.0'), 2.0);
expect(getId('/num/-2.4'), -2.4);
});
}