window.addEventListener testing with jasmine

Viewed 180

I have a question after searching for alot of hours but I'm unable to find a solution.

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?

0 Answers
Related