2016-10-20 09:21:59 +00:00
|
|
|
import 'package:angel_route/angel_route.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2016-10-21 03:13:13 +00:00
|
|
|
final String ARTIFICIAL_INDEX = 'artificial index';
|
|
|
|
|
|
|
|
tattle(x) => 'This ${x.runtimeType}.debug = ${x.debug}';
|
|
|
|
tattleAll(x) => x.map(tattle).join('\n');
|
|
|
|
|
2016-10-20 09:21:59 +00:00
|
|
|
main() {
|
2016-10-21 03:13:13 +00:00
|
|
|
final parent = new Router(debug: true);
|
|
|
|
final child = new Router(debug: true);
|
|
|
|
Route a, b, c;
|
|
|
|
|
|
|
|
a = child.get('a', ['c']);
|
|
|
|
child.group('b', (router) {
|
|
|
|
b = router.get('/', ARTIFICIAL_INDEX);
|
|
|
|
c = router.post('c', 'Hello nested');
|
|
|
|
});
|
|
|
|
|
2016-10-22 15:21:04 +00:00
|
|
|
parent.mount('child', child);
|
2016-10-21 03:13:13 +00:00
|
|
|
parent.dumpTree(header: tattleAll([parent, child, a]));
|
2016-10-20 09:21:59 +00:00
|
|
|
|
|
|
|
group('no params', () {
|
|
|
|
test('resolve', () {
|
2016-11-22 03:31:09 +00:00
|
|
|
expect(child.resolveOnRoot('a'), equals(a));
|
|
|
|
expect(child.resolveOnRoot('b'), equals(b));
|
|
|
|
expect(child.resolveOnRoot('b/c'), equals(c));
|
2016-10-21 03:13:13 +00:00
|
|
|
|
2016-11-22 03:31:09 +00:00
|
|
|
expect(parent.resolveOnRoot('child/a'), equals(a));
|
|
|
|
expect(parent.resolveOnRoot('a'), isNull);
|
|
|
|
expect(parent.resolveOnRoot('child/b'), equals(b));
|
|
|
|
expect(parent.resolveOnRoot('child/b/c'), equals(c));
|
2016-10-20 09:21:59 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|