/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import React from "react";
import "@testing-library/jest-dom/extend-expect";
import { render } from "@testing-library/react";
import PolicyInfo from "./PolicyInfo";
import { fireEvent } from "@testing-library/dom";
import userEvent from "@testing-library/user-event/dist";
describe(" spec", () => {
it("renders the component", () => {
const { container } = render(
{}}
onChangeDescription={() => {}}
/>
);
expect(container.firstChild).toMatchSnapshot();
});
it("calls on change policy id when typing in input", () => {
const onChangePolicyId = jest.fn();
const { getByTestId } = render(
{}}
/>
);
fireEvent.focus(getByTestId("create-policy-policy-id"));
userEvent.type(getByTestId("create-policy-policy-id"), `some_policy_id`);
expect(onChangePolicyId).toHaveBeenCalled();
});
it("calls on change description when typing in input", () => {
const onChangeDescription = jest.fn();
const { getByTestId } = render(
{}}
onChangeDescription={onChangeDescription}
/>
);
fireEvent.focus(getByTestId("create-policy-description"));
userEvent.type(getByTestId("create-policy-description"), `some description`);
expect(onChangeDescription).toHaveBeenCalled();
});
});