Tuesday, 30 November 2021

window.addEventListener testing with jasmine

I have a question after searching for allot of hours i didn't find a right direction.

service in AngularJS:

public webViewMessage = new Subject<any>();

constructor(private windowService: WindowService) {
 const wndw = this.windowService.getWindow();
 wndw?.chrome?.webview?.addEventListener('message', (event) => {
  this.webViewMessage.next(event.data);
 });
}

it is using WebView to receive data.

I'm trying to implement some jasmine tests for this but how do we hook into the addEventListener 'message' since its being used on window how do we raise this? and is there a way to do this some-how we need to Mock the window?



from window.addEventListener testing with jasmine

No comments:

Post a Comment