import * as React from "react";
import { render, cleanup, Simulate } from "react-testing-library";
import UnderlineAnimation from "../components/UnderlineAnimation";

beforeEach(cleanup);

describe("Underline Anmiation", () => {
    test("01 - component matches snapshot", () => {
        const { container } = render(
            <UnderlineAnimation children={<input />} />            
        );
        expect(container).toMatchSnapshot();
    });

    test('02: input focus', () => {
        const focus = jest.fn();
        const { getByTestId } = render(
            <UnderlineAnimation 
                children={<input onFocus={focus} data-testid={'input'} />}  
            />            
        );

        Simulate.focus(getByTestId('input'));
        expect(focus).toHaveBeenCalled();
    })
});
