feat(router): add support for componentless routes

This commit is contained in:
vsavkin
2016-06-19 14:44:20 -07:00
parent bd2281e32d
commit 92d8bf9619
11 changed files with 380 additions and 58 deletions

View File

@ -44,6 +44,32 @@ describe('create router state', () => {
expect(prevC[1]).not.toBe(currC[1]);
checkActivatedRoute(currC[1], ComponentC, 'left');
});
it('should handle componentless routes', () => {
const config = [
{ path: 'a/:id', children: [
{ path: 'b', component: ComponentA },
{ path: 'c', component: ComponentB, outlet: 'right' }
] }
];
const prevState = createRouterState(createState(config, "a/1;p=11/(b//right:c)"), emptyState());
advanceState(prevState);
const state = createRouterState(createState(config, "a/2;p=22/(b//right:c)"), prevState);
expect(prevState.root).toBe(state.root);
const prevP = prevState.firstChild(prevState.root);
const currP = state.firstChild(state.root);
expect(prevP).toBe(currP);
const prevC = prevState.children(prevP);
const currC = state.children(currP);
expect(currP._futureSnapshot.params).toEqual({id: '2', p: '22'});
checkActivatedRoute(currC[0], ComponentA);
checkActivatedRoute(currC[1], ComponentB, 'right');
});
});
function advanceState(state: RouterState): void {