Below mentioned code is working fine. which basically merge two events, merge them and do some operation on an input field. The problem is, I am not able to mock or write test cases for this code. Can anyone help me with this? I am using angular 12.
<input #myname value="John Doe">
ngAfterViewInit() {
const scrollEvents$ = fromEvent(this.input.nativeElement, 'blur');
const keyEvents$ = fromEvent(this.input.nativeElement, 'keyup').pipe(
filter((e: KeyboardEvent) => e.keyCode === 13)
);
const allEvents$ = merge(scrollEvents$, keyEvents$);
allEvents$
.pipe(
takeUntil(this.unsubscribe$),
map((evt: any) => evt.target.value),
distinctUntilChanged()
)
.subscribe((text: string) => {
this.data = text;
});
}