Skip to content

Commit

Permalink
test(packages/ui): Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nevendyulgerov committed Jan 16, 2025
1 parent e233f75 commit 3be51e3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/ui/test/GenericInputForm/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,37 @@ describe("GenericInputForm", () => {
fireEvent.click(submitButton);
expect(mockedWrite).toHaveBeenCalled();
});

it("should disable existing ABI option when no specifications are available", () => {
render(<Component {...defaultProps} specifications={[]} />);
const button = screen.getByText("ABI to Hex");
fireEvent.click(button);

const existingAbiOption = screen.getByText(
"ABI from an existing JSON_ABI specification",
).parentNode as HTMLDivElement;

expect(
existingAbiOption.getAttribute("data-combobox-disabled"),
).toBe("true");
expect(existingAbiOption.getAttribute("aria-selected")).toBe(
"false",
);
});

it("should preselect 'New ABI' option when no specifications are available", () => {
render(<Component {...defaultProps} specifications={[]} />);
const button = screen.getByText("ABI to Hex");
fireEvent.click(button);

const newAbiOption = screen.getByText("New ABI")
.parentNode as HTMLDivElement;

expect(newAbiOption.hasAttribute("data-combobox-disabled")).toBe(
false,
);
expect(newAbiOption.getAttribute("aria-selected")).toBe("true");
});
});

describe("Form", () => {
Expand Down

0 comments on commit 3be51e3

Please sign in to comment.