UNPKG

@sitecore/sc-contenthub-blok

Version:

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

43 lines 2.77 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 BlokLink_1 = require("./BlokLink"); describe("BlokLink", () => { test("renders children correctly", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", colorScheme: "red", children: "Red link" })); expect(react_1.screen.getByText("Red link")).toBeInTheDocument(); }); test("applies correct styles based on colorScheme", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", colorScheme: "blue", children: "Blue link" })); const link = react_1.screen.getByText("Blue link"); expect(link).toHaveStyle(`color: ${Foundations_1.colorMap["blue"][500]}`); }); test("applies underline on hover by default", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", children: "Hover link" })); const link = react_1.screen.getByText("Hover link"); expect(link).toHaveClass(BlokLink_1.classes.underlineOnHover); }); test("applies underline always when specified", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", underline: "always", children: "Always underline link" })); const link = react_1.screen.getByText("Always underline link"); expect(link).toHaveClass(BlokLink_1.classes.underlineAlways); }); test("applies no underline when specified", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", underline: "never", children: "Never underline link" })); const link = react_1.screen.getByText("Never underline link"); expect(link).toHaveClass(BlokLink_1.classes.underlineNever); }); test("defaults to primary colorScheme if none is provided", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", children: "Default link" })); const link = react_1.screen.getByText("Default link"); expect(link).toHaveStyle(`color: ${Foundations_1.colorMap["primary"][500]}`); }); test("should not crash when providing invalid colorScheme", () => { (0, react_1.render)((0, jsx_runtime_1.jsx)(BlokLink_1.BlokLink, { href: "www.google.com", colorScheme: "invalid", children: "Invalid link" })); const link = react_1.screen.getByText("Invalid link"); expect(link).toHaveStyle(`color: ${Foundations_1.colorMap["neutral"][500]}`); }); }); //# sourceMappingURL=BlokLink.spec.js.map