| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   TestComponentBuilder | 
					
						
							|  |  |  | } from 'angular2/testing_internal'; | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 14:07:57 -08:00
										 |  |  | import {SourceModule, moduleRef} from 'angular2/src/compiler/source_module'; | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('SourceModule', () => { | 
					
						
							|  |  |  |     describe('getSourceWithImports', () => { | 
					
						
							|  |  |  |       it('should generate named imports for modules', () => { | 
					
						
							|  |  |  |         var sourceWithImports = | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |             new SourceModule('package:some/moda', `${moduleRef('package:some/modb')}A`) | 
					
						
							|  |  |  |                 .getSourceWithImports(); | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |         expect(sourceWithImports.source).toEqual('import0.A'); | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |         expect(sourceWithImports.imports).toEqual([['package:some/modb', 'import0']]); | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should dedupe imports', () => { | 
					
						
							|  |  |  |         var sourceWithImports = | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |             new SourceModule( | 
					
						
							|  |  |  |                 'package:some/moda', | 
					
						
							|  |  |  |                 `${moduleRef('package:some/modb')}A + ${moduleRef('package:some/modb')}B`) | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |                 .getSourceWithImports(); | 
					
						
							|  |  |  |         expect(sourceWithImports.source).toEqual('import0.A + import0.B'); | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |         expect(sourceWithImports.imports).toEqual([['package:some/modb', 'import0']]); | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |       it('should not use an import for the moduleUrl of the SourceModule', () => { | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |         var sourceWithImports = | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |             new SourceModule('package:some/moda', `${moduleRef('package:some/moda')}A`) | 
					
						
							|  |  |  |                 .getSourceWithImports(); | 
					
						
							| 
									
										
										
										
											2015-09-14 15:59:09 -07:00
										 |  |  |         expect(sourceWithImports.source).toEqual('A'); | 
					
						
							|  |  |  |         expect(sourceWithImports.imports).toEqual([]); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |