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

describe("PillList tests", () => {
    test("01 - Render the component", async () => {
        const onClick: () => void = jest.fn();
        const component = (
            <PillList
                onClick={onClick} 
                items={['hello', 'world']}
            />
        );

        const wrapper = shallow(component);
        expect(wrapper.find({title: 'PillList'}).exists()).toBe(true);
    });
    test("02 - passing props correctly", () => {
        const onClick: () => void = jest.fn();
        const component = (
            <PillList
            onClick={onClick} 
            items={['hello', 'world']}
            />
        );
        const wrapper = shallow(component);
        expect(wrapper.getElement().props.children.length).toBe(2)
    });
    test("03 - automatic snapshot matching", () => {
        const onClick: () => void = jest.fn();
        const component = (
            <PillList
            onClick={onClick} 
            items={['hello', 'world']}
            />
        );
        const { container } = render(component);

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