Replace setImmediate with setTimeout (#12614)
This commit is contained in:
parent
21ae29c002
commit
8b4e3e6647
21 changed files with 46 additions and 39 deletions
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||
|
||||
import { mocked, Mocked } from "jest-mock";
|
||||
import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import { mkRoom, resetAsyncStoreWithClient, setupAsyncStoreWithClient, stubClient } from "../test-utils";
|
||||
|
@ -78,7 +79,7 @@ describe("leaveRoomBehaviour", () => {
|
|||
const expectDispatch = async <T extends ActionPayload>(payload: T) => {
|
||||
const dispatcherSpy = jest.fn();
|
||||
const dispatcherRef = defaultDispatcher.register(dispatcherSpy);
|
||||
await new Promise<void>((resolve) => setImmediate(resolve)); // Flush the dispatcher
|
||||
await sleep(0);
|
||||
expect(dispatcherSpy).toHaveBeenCalledWith(payload);
|
||||
defaultDispatcher.unregister(dispatcherRef);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue