When we think of using template in Angular2 or Angular1.X, we know below is one of the basic way of writing:
template: \'./template-ninja.html\'>
Use the following alternative:
it('should cache the result', inject([AsyncTestCompleter], (async) => {
PromiseWrapper
.all([ComponentResolver.resolveComponent(SomeComponent), ComponentResolver.resolveComponent(SomeComponent)])
.then((protoViewRefs) => {
expect(protoViewRefs[0]).toBe(protoViewRefs[1]);
async.done();
});
}));
Annotation is the other way to do it:
it('should read the template from an annotation',
inject([AsyncTestCompleter, Compiler], (async, compiler) => {
ComponentResolver.resolveComponent(SomeComponent)
.then((hostViewFactoryRef) => {
expect(hostViewFactoryRef.internalHostViewFactory).toBe(someHostViewFactory);
async.done();
});
}));
References