react-icons/fa#FaAnchor TypeScript Examples

The following examples show how to use react-icons/fa#FaAnchor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Input.test.tsx    From convoychat with GNU General Public License v3.0 5 votes vote down vote up
describe("<Input />", () => {
  it("should renders <Input>", () => {
    const { getByText, getByLabelText } = renderWithStyledTheme(
      <Input name="test" label="This is a label" defaultValue="hello world" />
    );
    expect(getByLabelText(/test/i)).toBeInTheDocument();
    expect(getByLabelText(/test/i)).toHaveValue("hello world");
    expect(getByText(/This is a label/i)).toBeInTheDocument();
  });

  it("should have icons", () => {
    const onPostfixIconClick = jest.fn();
    const { getByLabelText, getByTestId } = renderWithStyledTheme(
      <Input
        icon={FaCog}
        postfixIcon={FaAnchor}
        onPostfixIconClick={onPostfixIconClick}
        name="test"
        label="name"
        defaultValue="hello world"
      />
    );
    expect(getByLabelText(/test/i)).toBeInTheDocument();
    expect(getByTestId("input-icon")).toBeInTheDocument();
    expect(getByTestId("input-postfix-icon")).toBeInTheDocument();

    fireEvent.click(getByTestId("input-postfix-icon"));
    expect(onPostfixIconClick).toHaveBeenCalledWith(getByLabelText(/test/i));
  });

  it("should have errors", () => {
    const { getByLabelText, getByTestId } = renderWithStyledTheme(
      <Input
        errors={{ test: { type: "", message: "Invalid", isManual: true } }}
        name="test"
        label="name"
        defaultValue="hello world"
      />
    );
    expect(getByLabelText(/test/i)).toBeInTheDocument();
    expect(getByTestId("input-error")).toBeInTheDocument();
    expect(getByTestId("input-error")).toHaveTextContent("Invalid");
  });
});