React tests: Wrap code that causes state updates in `act()` (#2372)
This commit is contained in:
Родитель
2d68c1c735
Коммит
298176d8f1
|
@ -1,5 +1,10 @@
|
|||
import * as React from "react";
|
||||
import { render as reactRender, screen, waitFor } from "@testing-library/react";
|
||||
import {
|
||||
act,
|
||||
render as reactRender,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
import {
|
||||
VariantAnalysisRepoStatus,
|
||||
VariantAnalysisScannedRepositoryDownloadStatus,
|
||||
|
@ -319,11 +324,13 @@ describe(RepoRow.name, () => {
|
|||
status: VariantAnalysisRepoStatus.TimedOut,
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await userEvent.click(
|
||||
screen.getByRole("button", {
|
||||
expanded: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
screen.getByRole("button", {
|
||||
expanded: true,
|
||||
|
@ -342,11 +349,13 @@ describe(RepoRow.name, () => {
|
|||
interpretedResults: [],
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await userEvent.click(
|
||||
screen.getByRole("button", {
|
||||
expanded: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
expect(
|
||||
screen.getByRole("button", {
|
||||
|
@ -365,11 +374,13 @@ describe(RepoRow.name, () => {
|
|||
},
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await userEvent.click(
|
||||
screen.getByRole("button", {
|
||||
expanded: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
expect((window as any).vsCodeApi.postMessage).toHaveBeenCalledWith({
|
||||
t: "requestRepositoryResults",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from "react";
|
||||
import { render as reactRender, screen } from "@testing-library/react";
|
||||
import { act, render as reactRender, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import {
|
||||
VariantAnalysisRepoStatus,
|
||||
|
@ -155,11 +155,15 @@ describe(VariantAnalysisAnalyzedRepos.name, () => {
|
|||
expect(
|
||||
screen.queryByText("This is an empty block."),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
await act(async () => {
|
||||
await userEvent.click(
|
||||
screen.getByRole("button", {
|
||||
name: /octodemo\/hello-world-2/,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.getByText("This is an empty block.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче