From 3be51e3e7904be3cc458298d19e3b9698711c67c Mon Sep 17 00:00:00 2001 From: Neven Dyulgerov Date: Thu, 16 Jan 2025 13:48:22 +0200 Subject: [PATCH] test(packages/ui): Add unit tests --- .../ui/test/GenericInputForm/index.test.tsx | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/ui/test/GenericInputForm/index.test.tsx b/packages/ui/test/GenericInputForm/index.test.tsx index e51c396b..1ee80111 100644 --- a/packages/ui/test/GenericInputForm/index.test.tsx +++ b/packages/ui/test/GenericInputForm/index.test.tsx @@ -1050,6 +1050,37 @@ describe("GenericInputForm", () => { fireEvent.click(submitButton); expect(mockedWrite).toHaveBeenCalled(); }); + + it("should disable existing ABI option when no specifications are available", () => { + render(); + 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(); + 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", () => {