I have to test a function that uses the fromEvent observable function. Before the upgrade to 'lettable' operators, I was just doing this:
spyOn(Observable, 'fromEvent').and.callFake(mockFromEventFunction)
But now, Rxjs have changed, and Observable.fromEvent is just a function named fromEvent, that is imported like this: (and used the same way)
import { fromEvent } from 'rxjs/observable/fromEvent';
My question is, how I can mock that function with Jasmine spy utilities without knowing it's parent context?
I advise that this doesn't work:
import * as FromEventContext from 'rxjs/observable/fromEvent';
...
spyOn(FromEventContext , 'fromEvent').and.callFake(mockFromEventFunction)
Now I have a workaround wrapping that fromEvent in one Object which I know the context. But I am wondering how I can solve this cleanly.
Thanks in advance.