2015-04-17 12:59:56 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
describe,
|
|
|
|
it, iit,
|
|
|
|
ddescribe, expect,
|
|
|
|
inject, beforeEach,
|
|
|
|
SpyObject} from 'angular2/test_lib';
|
|
|
|
|
2015-05-01 08:53:38 -04:00
|
|
|
import {RouteRegistry} from 'angular2/src/router/route_registry';
|
2015-05-04 18:39:14 -04:00
|
|
|
import {RouteConfig} from 'angular2/src/router/route_config_impl';
|
2015-04-17 12:59:56 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('RouteRegistry', () => {
|
2015-05-01 08:53:38 -04:00
|
|
|
var registry,
|
|
|
|
rootHostComponent = new Object();
|
2015-04-17 12:59:56 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
registry = new RouteRegistry();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should match the full URL', () => {
|
2015-04-29 18:47:12 -04:00
|
|
|
registry.config(rootHostComponent, {'path': '/', 'component': DummyCompA});
|
|
|
|
registry.config(rootHostComponent, {'path': '/test', 'component': DummyCompB});
|
2015-04-17 12:59:56 -04:00
|
|
|
|
2015-05-01 08:53:38 -04:00
|
|
|
var instruction = registry.recognize('/test', rootHostComponent);
|
2015-04-17 12:59:56 -04:00
|
|
|
|
2015-04-29 18:47:12 -04:00
|
|
|
expect(instruction.getChildInstruction('default').component).toBe(DummyCompB);
|
2015-04-17 12:59:56 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should match the full URL recursively', () => {
|
2015-04-29 18:47:12 -04:00
|
|
|
registry.config(rootHostComponent, {'path': '/first', 'component': DummyParentComp});
|
2015-04-17 12:59:56 -04:00
|
|
|
|
2015-05-01 08:53:38 -04:00
|
|
|
var instruction = registry.recognize('/first/second', rootHostComponent);
|
2015-04-17 12:59:56 -04:00
|
|
|
|
2015-04-29 18:47:12 -04:00
|
|
|
var parentInstruction = instruction.getChildInstruction('default');
|
|
|
|
var childInstruction = parentInstruction.getChildInstruction('default');
|
|
|
|
|
|
|
|
expect(parentInstruction.component).toBe(DummyParentComp);
|
|
|
|
expect(childInstruction.component).toBe(DummyCompB);
|
2015-04-17 12:59:56 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
2015-04-29 18:47:12 -04:00
|
|
|
|
|
|
|
@RouteConfig([
|
|
|
|
{'path': '/second', 'component': DummyCompB }
|
|
|
|
])
|
|
|
|
class DummyParentComp {}
|
|
|
|
|
|
|
|
class DummyCompA {}
|
|
|
|
class DummyCompB {}
|