import * as React from "react";
import { render, screen, fireEvent, cleanup } from "@testing-library/react";

import Required from "./Required";

const testId = "FormBuilder-Attributes-Required";
const props = {};

describe("<Required /> Rendering Tests", () => {
  it(`Should render in the dom`, () => {
    render(<Required {...props} />);
    expect(screen.queryByTestId(testId)).toBeTruthy();
  });
});

describe("<Required /> Events Tests", () => {
  it(`Should trigger onChange when the Required field is toggled`, () => {
    const onChange = jest.fn();
    render(<Required {...props} onChange={onChange} />);
    fireEvent.click(
      screen.getByTestId(testId).querySelector(`input[type="checkbox"]`)
    );
    expect(onChange).toBeCalled();
  });
});
