platform/test/router/fallback.dart
2016-10-13 16:50:27 -04:00

20 lines
555 B
Dart

import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
bool checkPost(Route route) => route.method == "POST";
main() {
final router = new Router();
final userById = router.group('/user', (router) {
router.get('/:id', (id) => 'User $id');
}).resolve(':id');
final fallback = router.get('*', () => 'fallback');
test('resolve', () {
expect(router.resolve('/foo'), equals(fallback));
expect(router.resolve('/user/:id'), equals(userById));
expect(router.resolve('/user/:id', checkPost), isNull);
});
}