UNPKG

@sitecore/sc-contenthub-blok

Version:

A UI library for [Sitecore Content Hub](https://doc.sitecore.com/ch/).

44 lines 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("@testing-library/react"); const Foundations_1 = require("../../Foundations"); const BlokLabeledIcon_1 = require("./BlokLabeledIcon"); describe("BlokLabeledIcon", () => { test("renders with default props", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { children: "Default Label" })); expect(react_1.screen.getByText("Default Label")).toBeInTheDocument(); }); test("renders with icon and label", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { iconName: "check", children: "Label with Icon" })); expect(react_1.screen.getByText("Label with Icon")).toBeInTheDocument(); expect(react_1.screen.getByTestId("m-icon-check")).toBeInTheDocument(); }); test("applies correct styles for background color target", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { colorTarget: "background", colorScheme: "blue", children: "Background Label" })); const label = react_1.screen.getByText("Background Label"); expect(label).toHaveStyle(`background-color: ${Foundations_1.colorMap["blue"][100]}`); expect(label).toHaveStyle(`color: ${Foundations_1.colorMap["blue"][300]}`); }); test("applies correct styles for foreground color target", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { colorTarget: "foreground", colorScheme: "red", children: "Foreground Label" })); const label = react_1.screen.getByText("Foreground Label"); expect(label).toHaveStyle(`color: ${Foundations_1.colorMap["red"][500]}`); }); test("renders without children", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { iconName: "check" })); expect(react_1.screen.queryByText("Label")).not.toBeInTheDocument(); expect(react_1.screen.getByTestId("m-icon-check")).toBeInTheDocument(); }); test("applies custom className", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { className: "custom-class", children: "Custom Class Label" })); const label = react_1.screen.getByText("Custom Class Label"); expect(label).toHaveClass("custom-class"); }); test("should not crash when providing invalid colorScheme", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLabeledIcon_1.BlokLabeledIcon, { colorScheme: "invalid", children: "Invalid Label" })); const label = react_1.screen.getByText("Invalid Label"); expect(label).toHaveStyle(`color: ${Foundations_1.colorMap["neutral"][500]}`); }); }); //# sourceMappingURL=BlokLabeledIcon.spec.js.map