platform/packages/route/test/parse_test.dart

21 lines
483 B
Dart
Raw Normal View History

2021-05-14 07:02:50 +00:00
import 'package:angel3_route/angel3_route.dart';
2018-08-20 14:24:11 +00:00
import 'package:test/test.dart';
void main() {
2019-11-28 17:40:32 +00:00
var router = Router()
2018-08-20 14:24:11 +00:00
..get('/int/int:id', '')
..get('/double/double:id', '')
..get('/num/num:id', '');
2021-03-18 00:11:45 +00:00
num? getId(String path) {
2018-08-20 14:24:11 +00:00
var result = router.resolveAbsolute(path).first;
2021-03-18 00:11:45 +00:00
return result.allParams['id'] as num?;
2018-08-20 14:24:11 +00:00
}
test('parse', () {
expect(getId('/int/2'), 2);
expect(getId('/double/2.0'), 2.0);
expect(getId('/num/-2.4'), -2.4);
});
}