I have implement component communication using emit emitter service.
service.ts
import { EventEmitter, Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class BroadcastService {
updateDetails = new EventEmitter();
constructor() { }
}
i am emitting an event from component 1 using
this.broadcastService.updateDetails.emit();
and i'm subscribing to that event in component 2 as follows
this.broadcastService.updateDetails.subscribe(() => {
// code to executed after receiving the event
});
Now my question is
when i am writing unit test cases for component 2, how should i mock the 'broadcastService.updateDetails' so that subscribe method is called and the code inside the subscribe() should be covered in code coverage.