If I have a bit of code that cause something to happen async but not as a root cause of doing something (can't wait for the callback), something that happens on loop (i.e. testing autosave) how would be the best way todo it.
Here is a failing tests example of roughly what im trying to achieve.
function myProgram(something, onEvent) {
something().then(() => onEvent());
}
test('Promise test', () => {
const onEvent = jest.fn();
expect(onEvent).not.toBeCalled();
const doSomething = () => Promise.resolve();
myProgram(doSomething, onEvent);
expect(onEvent).toBeCalled(); // Expected mock function to have been called.
})