2015-10-01 13:07:49 -04:00
|
|
|
import {
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
xdescribe,
|
|
|
|
it,
|
|
|
|
iit,
|
|
|
|
xit,
|
|
|
|
expect,
|
|
|
|
beforeEach,
|
|
|
|
afterEach,
|
|
|
|
AsyncTestCompleter,
|
|
|
|
inject,
|
2015-11-11 08:28:23 -05:00
|
|
|
beforeEachProviders
|
2015-10-13 03:29:13 -04:00
|
|
|
} from 'angular2/testing_internal';
|
2015-10-01 13:07:49 -04:00
|
|
|
|
2015-10-11 01:11:13 -04:00
|
|
|
import {Component, View, provide} from 'angular2/core';
|
2015-11-06 20:34:07 -05:00
|
|
|
import {PromiseWrapper} from 'angular2/src/facade/async';
|
2015-12-02 13:35:51 -05: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 13:07:49 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('RuntimeCompiler', () => {
|
2015-12-02 13:35:51 -05: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 13:07:49 -04:00
|
|
|
});
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
beforeEach(inject([RuntimeCompiler], (_compiler) => { compiler = _compiler; }));
|
2015-10-01 13:07:49 -04:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
it('compileInHost should compile the template via TemplateCompiler',
|
|
|
|
inject([AsyncTestCompleter], (async) => {
|
|
|
|
compiler.compileInHost(SomeComponent)
|
|
|
|
.then((hostViewFactoryRef) => {
|
|
|
|
expect(hostViewFactoryRef.internalHostViewFactory).toBe(someHostViewFactory);
|
2015-10-01 13:07:49 -04:00
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
it('should clear the cache', () => {
|
|
|
|
compiler.clearCache();
|
|
|
|
expect(templateCompilerSpy.spy('clearCache')).toHaveBeenCalled();
|
|
|
|
});
|
2015-10-01 13:07:49 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({selector: 'some-comp'})
|
|
|
|
@View({template: ''})
|
|
|
|
class SomeComponent {
|
2015-10-02 10:37:23 -04:00
|
|
|
}
|