import React from "react"; import { createSerializer } from "@emotion/jest"; import { render, fireEvent, screen } from "@testing-library/react"; import { ConfigurationMap, ConfigurationMapSection, ConfigurationMapHeading, ConfigurationMapRow, ConfigurationMapLabel, ConfigurationMapValue, ConfigurationMapValueWithDefault, ConfigurationMapRowAction } from "../"; expect.addSnapshotSerializer(createSerializer()); describe("ConfigurationMap", () => { it("renders default", () => { const { asFragment } = render( Name Jane Doe Role UX Designer City San Francisco ); expect(asFragment()).toMatchSnapshot(); }); it("renders with headline", () => { const { asFragment } = render( Jane Doe Info Name Jane Doe Role UX Designer City San Francisco ); expect(asFragment()).toMatchSnapshot(); }); it("renders with actions", () => { const rowActionCallback = jest.fn(); const { asFragment } = render( Name Jane Doe Action Role UX Designer Action City San Francisco Action ); expect(asFragment()).toMatchSnapshot(); }); it("renders with default value", () => { const { asFragment } = render( Name Role City ); expect(asFragment()).toMatchSnapshot(); }); it("calls onClick when action is clicked", () => { const rowActionCallback = jest.fn(); render( Name Jane Doe Action Role UX Designer Action City San Francisco Action ); const button = screen.getAllByRole("button")[0]; expect(rowActionCallback).not.toHaveBeenCalled(); fireEvent.click(button); expect(rowActionCallback).toHaveBeenCalled(); }); });