| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   xdescribe, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   afterEach, | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   beforeEachProviders | 
					
						
							|  |  |  | } from 'angular2/testing_internal'; | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 13:36:48 -08:00
										 |  |  | import {Component, provide} from 'angular2/core'; | 
					
						
							| 
									
										
										
										
											2015-11-06 17:34:07 -08:00
										 |  |  | import {PromiseWrapper} from 'angular2/src/facade/async'; | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  | import {SpyTemplateCompiler} from './spies'; | 
					
						
							|  |  |  | import {TemplateCompiler} from 'angular2/src/compiler/compiler'; | 
					
						
							|  |  |  | import {RuntimeCompiler, RuntimeCompiler_} from 'angular2/src/compiler/runtime_compiler'; | 
					
						
							|  |  |  | import {HostViewFactory} from 'angular2/src/core/linker/view'; | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('RuntimeCompiler', () => { | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  |     var compiler: RuntimeCompiler_; | 
					
						
							|  |  |  |     var templateCompilerSpy; | 
					
						
							|  |  |  |     var someHostViewFactory; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     beforeEachProviders(() => { | 
					
						
							|  |  |  |       templateCompilerSpy = new SpyTemplateCompiler(); | 
					
						
							|  |  |  |       someHostViewFactory = new HostViewFactory(null, null); | 
					
						
							|  |  |  |       templateCompilerSpy.spy('compileHostComponentRuntime') | 
					
						
							|  |  |  |           .andReturn(PromiseWrapper.resolve(someHostViewFactory)); | 
					
						
							|  |  |  |       return [provide(TemplateCompiler, {useValue: templateCompilerSpy})]; | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  |     beforeEach(inject([RuntimeCompiler], (_compiler) => { compiler = _compiler; })); | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  |     it('compileInHost should compile the template via TemplateCompiler', | 
					
						
							|  |  |  |        inject([AsyncTestCompleter], (async) => { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |          compiler.compileInHost(SomeComponent) | 
					
						
							|  |  |  |              .then((hostViewFactoryRef) => { | 
					
						
							|  |  |  |                expect(hostViewFactoryRef.internalHostViewFactory).toBe(someHostViewFactory); | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-02 10:35:51 -08:00
										 |  |  |     it('should clear the cache', () => { | 
					
						
							|  |  |  |       compiler.clearCache(); | 
					
						
							|  |  |  |       expect(templateCompilerSpy.spy('clearCache')).toHaveBeenCalled(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-08 13:36:48 -08:00
										 |  |  | @Component({selector: 'some-comp', template: ''}) | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | class SomeComponent { | 
					
						
							| 
									
										
										
										
											2015-10-02 07:37:23 -07:00
										 |  |  | } |