I want to test an event (dialogEvent
) which is being triggered from a material dialog instance with ts-mockito:
myFunc() {
this.matDialogRef = this.matDialog.open(DialogComponent);
this.matDialogRef.componentInstance.dialogEvent.subscribe(() => {
this.doSomething();
});
}
How can I spy on or mock it in my test?
it('should call doSomething() on dialogEvent', () => {
// trigger DialogComponent.dialogEvent event here
expect(comp.doSomething).toHaveBeenCalled();
});