import * as React from "react"; import generate from "../../testUtils/utils"; import { render, wait, } from "react-testing-library"; import { shallow } from "enzyme"; import InputPillList from "../components/InputPillList/index"; describe("InputPillList tests", () => { test("01 - Render the component", async () => { const onClick: () => void = jest.fn(); const updateItems: (items) => void = jest.fn(); const component = ( ); const wrapper = shallow(component); expect(wrapper.find('div').length).toEqual(1); }); test("02 - Passing props", () => { const onClick: () => void = jest.fn(); const updateItems: (items) => void = jest.fn(); const component = ( ); const wrapper = shallow(component); expect(wrapper.instance().props.items).toEqual(['hello', 'world']); }); test("03 - automatic snapshot matching", () => { const onClick: () => void = jest.fn(); const updateItems: (items) => void = jest.fn(); const component = ( ); const { container } = render(component); expect(container).toMatchSnapshot(); }); test("04 - onChangeText", async () => { const onClick: () => void = jest.fn(); const updateItems: (items) => void = jest.fn(); const component = ( ); const wrapper = shallow(component); wrapper.setState({ inputText: '' }); await wait(() => expect(wrapper.state().inputText).toBe('')); wrapper.instance().onChangeText('newPill'); expect(wrapper.state().inputText).toEqual('newPill'); }); });