import { render, screen } from "@testing-library/react";
import CatalogGroup from "../../../lib/ReactViews/DataCatalog/CatalogGroup";
import { ThemeProvider } from "styled-components";
import { terriaTheme } from "../../../lib/ReactViews/StandardUserInterface";
describe("CatalogGroup React", () => {
describe("Loading", () => {
it("Shows loader", () => {
render(
{}} loading emptyMessage="nothing here" />
);
// Loader renders a spinning element
expect(screen.getByText("loader.loadingMessage")).toBeVisible();
// No empty message
expect(screen.queryByText("nothing here")).not.toBeInTheDocument();
});
it("Doesn't show children when loading", () => {
render(
{}} loading>
some child
);
expect(screen.getByText("loader.loadingMessage")).toBeVisible();
expect(screen.queryByText("some child")).not.toBeInTheDocument();
});
it("Shows children when not loading", () => {
render(
{}} loading={false}>
some child
);
expect(
screen.queryByText("loader.loadingMessage")
).not.toBeInTheDocument();
expect(screen.getByText("some child")).toBeTruthy();
});
});
describe("Empty", () => {
it("Shows empty message", () => {
render(
{}}
open
emptyMessage="nothing here"
loading={false}
>
{[]}
);
expect(screen.getByText("nothing here")).toBeTruthy();
});
});
});