platform/test/wildcard_test.dart

26 lines
713 B
Dart
Raw Normal View History

2017-11-28 21:07:14 +00:00
import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
void main() {
var router = new Router();
router.get('/songs/*/key', 'of life');
router.get('/isnt/she/*', 'lovely');
router.all('*', 'stevie');
test('match until end if * is last', () {
var result = router.resolveAbsolute('/wonder').first;
expect(result.handlers, ['stevie']);
});
test('match if not last', () {
var result = router.resolveAbsolute('/songs/what/key').first;
expect(result.handlers, ['of life']);
});
test('match if segments before', () {
2018-08-20 19:34:00 +00:00
var result =
router.resolveAbsolute('/isnt/she/fierce%20harmonica%solo').first;
2017-11-28 21:07:14 +00:00
expect(result.handlers, ['lovely']);
});
2018-08-20 19:34:00 +00:00
}