Skip to content

Commit

Permalink
feat: update unit test for shrink
Browse files Browse the repository at this point in the history
Signed-off-by: suzhou <[email protected]>
  • Loading branch information
SuZhou-Joe authored and Hailong-am committed Nov 9, 2022
1 parent 3e69ff3 commit 84137f6
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React from "react";
import "@testing-library/jest-dom/extend-expect";
import { render, fireEvent, waitFor } from "@testing-library/react";
import { render, fireEvent, waitFor, act } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import ShrinkIndexFlyout from "./ShrinkIndexFlyout";

Expand Down Expand Up @@ -80,11 +80,11 @@ describe("<ShrinkIndexFlyout /> spec", () => {

it("shows error when number of shards is not valid", async () => {
const onClose = jest.fn();
const { getByTestId, queryByText, debug } = render(
const { getByTestId, getByText } = render(
<ShrinkIndexFlyout
sourceIndex={{
health: "green",
index: "test_index",
index: "test_index123",
pri: "3",
rep: "0",
status: "open",
Expand All @@ -97,12 +97,12 @@ describe("<ShrinkIndexFlyout /> spec", () => {
);

userEvent.type(getByTestId("numberOfShardsInput"), "2");
fireEvent.click(getByTestId("shrinkIndexConfirmButton"));
await waitFor(() => {
expect(
queryByText("The number of new primary shards must be a positive factor of the number of primary shards in the source index.")
).not.toBeNull();
await act(async () => {
await userEvent.click(getByTestId("shrinkIndexConfirmButton"));
});
expect(
getByText("The number of new primary shards must be a positive factor of the number of primary shards in the source index.")
).not.toBeNull();
});

it("no error when number of shards is valid", async () => {
Expand Down

0 comments on commit 84137f6

Please sign in to comment.