我正在服务规范中创建动态组件。
createComponent
,此方法将根据其类型创建组件。
createComponent(content, type: any) {
if (!type) {
return this.redirectToRootPath();
}
this.componentFactory = this.componentFactoryResolver.resolveComponentFactory(type);
this.componentReference = this.rootViewContainer.createComponent(this.componentFactory);
this.componentReference.instance.contentOnCreate(content);
}
下面是我写的规范,
it('should call createComponent ', () => {
spyOn(renderEngineService, 'setRootViewContainerRef');
spyOn(renderEngineService, 'createComponent');
renderEngineService.createComponent(NO_INLINE_RANGES, 'HeadingComponent');
expect(renderEngineService.createComponent).toHaveBeenCalled();
});
问题是,我收到了一条评论
quite a pointless spy if you call the function yourself :P
那么如何重新编写此规范?
请帮助