BREAKING CHANGE: - Platform pipes can only contain types and arrays of types, but no bindings any more. - When using transformers, platform pipes need to be specified explicitly in the pubspec.yaml via the new config option `platform_pipes`. - `Compiler.compileInHost` now returns a `HostViewFactoryRef` - Component view is not yet created when component constructor is called. -> use `onInit` lifecycle callback to access the view of a component - `ViewRef#setLocal` has been moved to new type `EmbeddedViewRef` - `internalView` is gone, use `EmbeddedViewRef.rootNodes` to access the root nodes of an embedded view - `renderer.setElementProperty`, `..setElementStyle`, `..setElementAttribute` now take a native element instead of an ElementRef - `Renderer` interface now operates on plain native nodes, instead of `RenderElementRef`s or `RenderViewRef`s Closes #5993
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import {
 | 
						|
  ddescribe,
 | 
						|
  describe,
 | 
						|
  xdescribe,
 | 
						|
  it,
 | 
						|
  iit,
 | 
						|
  xit,
 | 
						|
  expect,
 | 
						|
  beforeEach,
 | 
						|
  afterEach,
 | 
						|
  AsyncTestCompleter,
 | 
						|
  inject,
 | 
						|
  beforeEachProviders
 | 
						|
} from 'angular2/testing_internal';
 | 
						|
 | 
						|
import {Component, View, provide} from 'angular2/core';
 | 
						|
import {PromiseWrapper} from 'angular2/src/facade/async';
 | 
						|
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';
 | 
						|
 | 
						|
export function main() {
 | 
						|
  describe('RuntimeCompiler', () => {
 | 
						|
    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})];
 | 
						|
    });
 | 
						|
 | 
						|
    beforeEach(inject([RuntimeCompiler], (_compiler) => { compiler = _compiler; }));
 | 
						|
 | 
						|
    it('compileInHost should compile the template via TemplateCompiler',
 | 
						|
       inject([AsyncTestCompleter], (async) => {
 | 
						|
         compiler.compileInHost(SomeComponent)
 | 
						|
             .then((hostViewFactoryRef) => {
 | 
						|
               expect(hostViewFactoryRef.internalHostViewFactory).toBe(someHostViewFactory);
 | 
						|
               async.done();
 | 
						|
             });
 | 
						|
       }));
 | 
						|
 | 
						|
    it('should clear the cache', () => {
 | 
						|
      compiler.clearCache();
 | 
						|
      expect(templateCompilerSpy.spy('clearCache')).toHaveBeenCalled();
 | 
						|
    });
 | 
						|
  });
 | 
						|
}
 | 
						|
 | 
						|
@Component({selector: 'some-comp'})
 | 
						|
@View({template: ''})
 | 
						|
class SomeComponent {
 | 
						|
}
 |