I have this function
public pick(config?: FilePickerConfig): Promise<FilePickerResult> {
return new Promise<FilePickerResult>(resolve => {
this.pickWithCallbacks(resolve, resolve, config);
});
}
I want to test if the call to this.pickWithCallbacks
has as first and second parameter the resolve
parameter of the function.
Is there a way to do this in jest or jasmine? I have tried to spy on window, 'Promise'
but it does not work.
Edit: It is not a depulicate of Spying on a constructor using Jasmine because that is what I have tried and did not work.
I have tried this:
const dummyResolve = () => { };
const promiseSpy = spyOn(window, 'Promise').and.callFake((dummyResolve)=>{});
const pickWithCallbacksSpy = spyOn(sut, 'pickWithCallbacks');
sut.pick();
expect(pickWithCallbacksSpy).toHaveBeenCalledWith(dummyResolve, dummyResolve, undefined);