Replace setImmediate with setTimeout (#12614)
This commit is contained in:
parent
21ae29c002
commit
8b4e3e6647
21 changed files with 46 additions and 39 deletions
|
@ -18,6 +18,7 @@ import React, { ComponentProps } from "react";
|
|||
import { render, fireEvent, RenderResult, waitFor } from "@testing-library/react";
|
||||
import { Room, RoomMember, MatrixError, IContent } from "matrix-js-sdk/src/matrix";
|
||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import { withClientContextRenderOptions, stubClient } from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
|
@ -373,7 +374,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
if (expectSecondaryButton) expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
|
@ -387,7 +388,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
|
||||
it("renders error message", async () => {
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
});
|
||||
|
@ -404,7 +405,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
|
||||
it("renders invite message with invited email", async () => {
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
});
|
||||
|
@ -420,7 +421,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
|
||||
it("renders invite message with invited email", async () => {
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
});
|
||||
|
@ -438,7 +439,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
it("renders email mismatch message when invite email mxid doesnt match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: "not userid" });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
expect(MatrixClientPeg.safeGet().lookupThreePid).toHaveBeenCalledWith(
|
||||
|
@ -452,7 +453,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
it("renders invite message when invite email mxid match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: userId });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
await testJoinButton({ inviterName, invitedEmail }, false)();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue