【发布时间】:2017-08-04 08:31:49
【问题描述】:
我有一个模式,只要用户选择页面的菜单选项,它就会打开。我遇到的问题是我不知道如何让它在我的ngOnInit中调用我的函数调用
test.component.ts
constructor(public dialog: MdDialog) { }
ngOnInit() {
this.openTestModal();
}
openTestModal() {
this.dialog.open(TestModalComponent, {
disableClose: true,
width: '600px'
});
}
我已经导入了我的模型组件并尝试了:
change-password.component.spec.ts
import { TestModalComponent } from '../test-modal/test-modal.component';
spyOn(component, 'openTestModal');
spyOn(component, 'ngOnInit').and.callThrough();
it('should be created', () => {
expect(component).toBeTruthy();
});
错误
没有为 TestComponent 找到组件工厂。你添加到 @NgModule.entryComponents?
但它已经在里面了
【问题讨论】:
标签: unit-testing jasmine karma-jasmine