import * as React from "react";
import generate from "../../testUtils/utils";
import {
    render,
} from "react-testing-library";
import { shallow } from "enzyme";
import Pill from "../components/Pill";

describe("Pill tests", () => {
    test("01 - Render the component", async () => {
        const onClick: () => void = jest.fn();
        const component = (
            <Pill
                onClick={onClick} 
                name={'pill'}
            />
        );

        const wrapper = shallow(component);
        expect(wrapper.find('#pill').length).toBe(1);
    });
    test("02 - passing props correctly", () => {
        const onClick: () => void = jest.fn();
        const component = (
            <Pill
                onClick={onClick} 
                name={'pill name'}
            />
        );
        const wrapper = shallow(component);
        expect(wrapper.props().id).toBe('pill name')
    });
    test("03 - automatic snapshot matching", () => {
        const onClick: () => void = jest.fn();
        const component = (
            <Pill
                onClick={onClick} 
                name={'pill name'}
            />
        );
        const { container } = render(component);

        expect(container).toMatchSnapshot();
    });
});