Mock function with jest that contains a callback as an argument which returns a promise
问题 I'm integrating with a 3rd party script and have come across a scenario which I don't know how to test properly. The 3rd party script adds an object to the window with a few methods. The second argument of the create method is a callback function which returns a promise that is either rejected or resolved. I need to be able to mock that second argument with either a reject or resolved status so that my unit test can cover whether the UI is updated with either the error or success message. How