From 726b16123a62646bd9fbbeedd6cbcf16e1501066 Mon Sep 17 00:00:00 2001 From: Daniel Eshkeri Date: Wed, 4 Dec 2024 18:18:56 +0000 Subject: [PATCH] reverted fab change --- src/test/fab/fab.test.ts | 103 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/src/test/fab/fab.test.ts b/src/test/fab/fab.test.ts index 9577e97..fdc11b1 100644 --- a/src/test/fab/fab.test.ts +++ b/src/test/fab/fab.test.ts @@ -1,6 +1,6 @@ import { expect, fixture, html, unsafeStatic } from "@open-wc/testing"; import type { ZetaFab } from "../../components/fab/fab.js"; -// import { getCssVarValue } from "../utils.js"; +import { getCssVarValue } from "../utils.js"; import "../../components/fab/fab.js"; import "../../index.css"; @@ -29,6 +29,107 @@ describe("zeta-fab", () => { }); }); + describe("Content Tests", () => { + it("renders a button with a label", () => { + expect(subject.shadowRoot?.querySelector("button")).to.exist; + expect(subject.shadowRoot?.querySelector(".label")).to.exist; + }); + + it("renders a button with an icon", () => { + expect(subject.shadowRoot?.querySelector("zeta-icon")).to.exist; + }); + + it("renders no label when label is empty", async () => { + subject.label = ""; + await subject.updateComplete; + expect(subject.shadowRoot?.querySelector(".label")).to.not.exist; + }); + + it("renders an extended fab", async () => { + subject.extended = true; + await subject.updateComplete; + const labelExtentedFab = subject.shadowRoot?.querySelector("button .label"); + const labelDefault = subject.shadowRoot?.querySelector(":host > .label"); + await expect(subject.extended).to.equal(true); + expect(labelExtentedFab).to.exist; + expect(labelDefault).to.not.exist; + }); + + it("renders a default fab", async () => { + const labelExtentedFab = subject.shadowRoot?.querySelector("button .label"); + const labelDefault = subject.shadowRoot?.querySelector(":host > .label"); + await expect(subject.extended).to.equal(false); + expect(labelExtentedFab).to.not.exist; + expect(labelDefault).to.exist; + }); + }); + + describe("Dimensions Tests", () => { + it("renders a small fab", async () => { + const el = subject.shadowRoot?.querySelector("button"); + const height = getComputedStyle(el!).height; + const expectedHeight = parseInt(getCssVarValue(el!, "--spacing-medium")) * 2 + 24 + "px"; + await expect(subject.size).to.equal("small"); + await expect(height).to.equal(expectedHeight); + }); + + it("renders a large fab", async () => { + const fab: ZetaFab = await fixture(html``); + + const el = fab.shadowRoot?.querySelector("button"); + const height = getComputedStyle(el!).height; + const expectedHeight = parseInt(getCssVarValue(el!, "--spacing-xl")) * 2 + 36 + "px"; + await expect(height).to.equal(expectedHeight); + }); + }); + + describe("Styling Tests", () => { + it("renders a full rounded fab", async () => { + const el = subject.shadowRoot?.querySelector("button"); + const borderRadius = getComputedStyle(el!).borderRadius; + const expectedBorderRadius = getCssVarValue(el!, "--radius-full"); + await expect(subject.round).to.equal("full"); + await expect(borderRadius).to.equal(expectedBorderRadius); + }); + + it("renders a rounded small fab", async () => { + const fab: ZetaFab = await fixture(html``); + + const el = fab.shadowRoot?.querySelector("button"); + fab.round = true; + await fab.updateComplete; + const borderRadius = getComputedStyle(el!).borderRadius; + const expectedBorderRadius = getCssVarValue(el!, "--radius-rounded"); + await expect(fab.round).to.equal(true); + await expect(borderRadius).to.equal(expectedBorderRadius); + }); + + it("renders a rounded large fab", async () => { + const fab: ZetaFab = await fixture(html``); + + const el = fab.shadowRoot?.querySelector("button"); + fab.round = true; + await fab.updateComplete; + const borderRadius = getComputedStyle(el!).borderRadius; + const expectedBorderRadius = getCssVarValue(el!, "--radius-large"); + await expect(fab.round).to.equal(true); + await expect(fab.size).to.equal("large"); + await expect(borderRadius).to.equal(expectedBorderRadius); + }); + + it("renders a non-rounded fab", async () => { + const fab: ZetaFab = await fixture(html``); + + const el = fab.shadowRoot?.querySelector("button"); + fab.round = false; + await fab.updateComplete; + const borderRadius = getComputedStyle(el!).borderRadius; + const expectedBorderRadius = getCssVarValue(el!, "--radius-none"); + await expect(fab.round).to.equal(false); + await expect(borderRadius).to.equal(expectedBorderRadius); + }); + }); + // describe("Interaction Tests", () => {}); // describe("Golden Tests", () => {});