import { html, fixture, expect } from "@open-wc/testing"; import IconPack from "@cldcvr/flow-system-icon/dist/types/icon-pack"; // importing flow-core components import "@cldcvr/flow-core"; import { FBreadcrumb, ConfigUtil } from "@cldcvr/flow-core"; // setting icon pack for testing icon related test cases ConfigUtil.setConfig({ iconPack: IconPack }); describe("f-breadcrumb", () => { it("is defined", () => { const el = document.createElement("f-breadcrumb"); expect(el).instanceOf(FBreadcrumb); }); it("should render with default values", async () => { const el = await fixture(html` `); expect(el.getAttribute("size")).to.equal("medium"); expect(el.getAttribute("variant")).to.equal("text"); }); it("should render with x-small text-size when size is small", async () => { const el = await fixture(html` `); const descendant = el.shadowRoot!.querySelector(".f-breadcrumb-text-hover")!; expect(descendant.getAttribute("size")).to.equal("x-small"); }); it("should render with proper crumb list", async () => { const el = await fixture(html` `); const descendant = el.shadowRoot!.querySelectorAll(".f-breadcrumb-content")!; expect(descendant.length).to.equal(2); }); it("should render with crumbs inside poppover when crumb length is more than 4", async () => { const el = await fixture(html` `); const descendant = el.shadowRoot!.querySelectorAll(".popover-crumb-list")!; expect(descendant.length).to.equal(2); }); it("should render with icon variant crumbs", async () => { const el = await fixture(html` `); const descendant = el.shadowRoot!.querySelector(".f-breadcrumbs")!; expect(descendant.children.length).to.equal(5); }); it("should render with icon variant and the last crumb should be in active primary mode", async () => { const el = await fixture(html` `); const descendants = el.shadowRoot!.querySelector(".f-breadcrumbs")!; const selected = descendants.children[descendants.children.length - 1]; const text = selected.querySelector("f-text")!; expect(text.innerHTML).includes("Active"); }); });