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