Replace setImmediate with setTimeout (#12614)
This commit is contained in:
@@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
import { mocked } from "jest-mock";
|
||||
import { SyncState } from "matrix-js-sdk/src/matrix";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import ToastStore from "../../src/stores/ToastStore";
|
||||
@@ -40,7 +41,7 @@ describe("LifecycleStore", () => {
|
||||
prevState: SyncState.Prepared,
|
||||
});
|
||||
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(addOrReplaceToast).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -58,7 +59,7 @@ describe("LifecycleStore", () => {
|
||||
prevState: SyncState.Prepared,
|
||||
});
|
||||
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
expect(addOrReplaceToast).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -77,7 +78,7 @@ describe("LifecycleStore", () => {
|
||||
prevState: SyncState.Prepared,
|
||||
});
|
||||
|
||||
await new Promise(setImmediate);
|
||||
await sleep(0);
|
||||
|
||||
addOrReplaceToast.mock.calls[0][0].props.onAccept();
|
||||
|
||||
|
||||
@@ -323,7 +323,6 @@ describe("RoomListStore", () => {
|
||||
const algorithmSpy = jest.spyOn(store.algorithm, "handleRoomUpdate").mockReturnValue(undefined);
|
||||
// @ts-ignore cheat and call protected fn
|
||||
store.onAction({ action: "MatrixActions.accountData", event, previousEvent });
|
||||
// flush setImmediate
|
||||
await flushPromises();
|
||||
|
||||
expect(algorithmSpy).toHaveBeenCalledWith(normalRoom, RoomUpdateCause.PossibleMuteChange);
|
||||
@@ -346,7 +345,6 @@ describe("RoomListStore", () => {
|
||||
|
||||
// @ts-ignore cheat and call protected fn
|
||||
store.onAction({ action: "MatrixActions.accountData", event, previousEvent });
|
||||
// flush setImmediate
|
||||
await flushPromises();
|
||||
|
||||
// only one call to update made for normalRoom
|
||||
|
||||
Reference in New Issue
Block a user