Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon committed May 29, 2024
1 parent 20131dc commit 861a974
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions apps/spruce/src/components/Settings/Form.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getTestUtils } from "@leafygreen-ui/text-input";
import { ValidateProps } from "components/SpruceForm";
import { render, screen, userEvent } from "test_utils";
import { Form, FormProps } from "./Form";
Expand Down Expand Up @@ -57,23 +56,22 @@ describe("context-based form", () => {
render(<Component tab="bar" validate={barValidator} />, {
wrapper: TestProvider,
});
const { getInput } = getTestUtils("lg-age-input");
await user.clear(getInput());
expect(getInput()).toHaveValue("");
await user.clear(screen.getByLabelText("Age"));
expect(screen.getByLabelText("Age")).toHaveValue("");
expect(screen.queryByText("Invalid Age!")).not.toBeInTheDocument();
await user.type(getInput(), "30");
await user.type(screen.getByLabelText("Age"), "30");
expect(screen.getByText("Invalid Age!")).toBeInTheDocument();
});

it("disables the entire form when specified", () => {
render(<Component tab="bar" disabled />, {
wrapper: TestProvider,
});
expect(screen.getAllByLabelText("Name")[0]).toHaveAttribute(
expect(screen.getByLabelText("Name")).toHaveAttribute(
"aria-disabled",
"true",
);
expect(screen.getAllByLabelText("Age")[0]).toHaveAttribute(
expect(screen.getByLabelText("Age")).toHaveAttribute(
"aria-disabled",
"true",
);
Expand Down Expand Up @@ -118,13 +116,6 @@ const formSchema = {
},
},
},
uiSchema: {
name: {
"ui:data-lgid": "lg-name-input",
},
age: {
"ui:data-lgid": "lg-age-input",
},
},
uiSchema: {},
},
};

0 comments on commit 861a974

Please sign in to comment.