import{newSpecPage}from"@stencil/core/testing";import{ScSelectDropdown}from"../sc-select";describe("sc-select-dropdown",(()=>{it("renders",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:"<sc-select-dropdown></sc-select-dropdown>"});expect(e.root).toMatchSnapshot()})),it("renders a focusable host by default",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:"<sc-select></sc-select>"});expect(e.root.getAttribute("tabindex")).toBe("0"),expect(e.root.getAttribute("role")).toBe("button"),expect(e.root.getAttribute("aria-haspopup")).toBe("listbox")})),it("removes the host from the tab order when disabled",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:"<sc-select disabled></sc-select>"});expect(e.root.getAttribute("tabindex")).toBe("-1")})),it("reflects the open prop on aria-expanded",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:"<sc-select></sc-select>"});expect(e.root.getAttribute("aria-expanded")).toBe("false"),e.root.open=!0,await e.waitForChanges(),expect(e.root.getAttribute("aria-expanded")).toBe("true")})),it("builds the host aria-label from the label and placeholder when there is no value",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:'<sc-select label="Country" placeholder="Choose a country"></sc-select>'});expect(e.root.getAttribute("aria-label")).toBe("Country, Choose a country")})),it("falls back to the placeholder for the host aria-label when there is no label",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:'<sc-select placeholder="Choose a country"></sc-select>'});expect(e.root.getAttribute("aria-label")).toBe("Choose a country")})),it("emits scFocus only once when the host gains focus",(async()=>{const e=await newSpecPage({components:[ScSelectDropdown],html:"<sc-select></sc-select>"}),t=jest.fn();e.root.addEventListener("scFocus",t),e.rootInstance.handleFocus(),await e.waitForChanges(),expect(t).toHaveBeenCalledTimes(1)})),it("does not render the invalid select role on the dropdown",(async()=>{const e=(await newSpecPage({components:[ScSelectDropdown],html:"<sc-select></sc-select>"})).root.shadowRoot.querySelector("sc-dropdown");expect(e.getAttribute("role")).toBeNull(),expect(e.hasAttribute("aria-open")).toBe(!1)}))}));