platform/packages/route/test/parse_test.dart
thomashii@dukefirehawk.com 7c37497860 Publish angel3_route
2021-05-14 15:02:50 +08:00

20 lines
483 B
Dart

import 'package:angel3_route/angel3_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);
});
}