/* * Copyright 2024 Palantir Technologies, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { render, screen } from "@testing-library/react"; import { describe, expect, it } from "@blueprintjs/test-commons/vitest"; import { Classes } from "../../common"; import { Tag } from "../../index"; import { H5 } from "../html/html"; import { EntityTitle } from "./entityTitle"; describe("", () => { it("supports className", () => { const { container } = render(); expect(container.querySelector("h5")).not.toBeInTheDocument(); expect(container.querySelector(".foo")).toBeInTheDocument(); }); it("renders title", () => { render(); const title = screen.getByText("title"); expect(title).toHaveClass(Classes.ENTITY_TITLE_TITLE); }); it("renders title in heading", () => { render(); const title = screen.getByText("title"); expect(title.tagName.toLowerCase()).toBe("h5"); }); it("supports icon", () => { const { container } = render(); expect(container.querySelector(`[data-icon="graph"]`)).toBeInTheDocument(); }); it("omitting icon prop removes icon from DOM", () => { const { container } = render(); expect(container.querySelector("[data-icon]")).not.toBeInTheDocument(); }); it("supports tag", () => { render(tag} />); expect(screen.getByText("tag")).toBeInTheDocument(); }); it("renders optional subtitle element", () => { render(); expect(screen.getByText("subtitle")).toBeInTheDocument(); }); it("renders title in an anchor", () => { render(); const title = screen.getByText("title"); expect(title.tagName.toLowerCase()).toBe("a"); expect(title).toHaveAttribute("href", "https://blueprintjs.com/"); }); it("supports ellipsize on Text", () => { render(); const title = screen.getByText("title"); expect(title).toHaveClass(Classes.TEXT_OVERFLOW_ELLIPSIS); }); it("supports ellipsize on heading", () => { render(); const title = screen.getByText("title"); expect(title).toHaveClass(Classes.TEXT_OVERFLOW_ELLIPSIS); }); it("supports fill", () => { const { container } = render(); expect(container.querySelector(`.${Classes.FILL}`)).toBeInTheDocument(); }); it("supports loading", () => { render(); const title = screen.getByText("title"); expect(title).toHaveClass(Classes.SKELETON); }); });