// Mockup https://www.figma.com/design/zsq2ahat30acTnumyy9aqC/00.Small-System?node-id=22-890&m=dev /* * Expect named slots (icon, label) or attributes (icon, label) * Can have a active attribute * Should emit a click event if not disabled or not active */ import { html } from "lit"; import "~icons/mingcute/search-3-line"; describe("", () => { it("should mount", () => { cy.mount(html``); cy.get("tems-breadcrumb-item").should("exist"); }); const defaultLabel = "Label"; const defaultIcon = html``; const defaultIconAsSlot = html``; it("should display label", () => { cy.mount( html``, ); cy.get("tems-breadcrumb-item").contains(defaultLabel); }); it("should handle active attribute", () => { cy.mount( html``, ); cy.get("tems-breadcrumb-item") .find("button") .should("have.css", "background-color", "rgba(0, 0, 0, 0)"); cy.mount( html``, ); cy.get("tems-breadcrumb-item") .find("button") .should("have.css", "background-color", "rgb(255, 33, 242)"); }); it("should handle icon attribute", () => { cy.mount( html``, ); cy.get("tems-breadcrumb-item") .find("button") .find("icon-mingcute-search-3-line") .should("exist"); }); it("should accept slots", () => { cy.mount( html`${defaultLabel}`, ); cy.get("tems-breadcrumb-item").find("button").find("slot").should("exist"); }); it("should accept named slots", () => { cy.mount( html`${defaultLabel}`, ); cy.get("tems-breadcrumb-item") .find("button") .find("slot[name='label']") .should("exist"); cy.mount( html`${defaultIconAsSlot}`, ); cy.get("tems-breadcrumb-item") .find("button") .find("slot[name='icon']") .should("exist"); cy.mount( html`${defaultLabel}${defaultIconAsSlot}`, ); cy.get("tems-breadcrumb-item").find("button").as("button"); cy.get("@button").find("slot[name='icon']").should("exist"); cy.get("@button").find("slot[name='label']").should("exist"); }); it("should emit a click event", () => { const onClickedSpy = cy.spy().as("handleClick"); cy.mount( html``, ); cy.get("tems-breadcrumb-item").find("button").click(); cy.get("@handleClick").should("have.been.called"); }); it("should not emit a click event when active", () => { const onClickedSpy = cy.spy().as("handleClick"); cy.mount( html``, ); cy.get("tems-breadcrumb-item").find("button").click(); cy.get("@handleClick").should("not.have.been.calledWith", { detail: Cypress.sinon.match(Object), }); }); });