import React from 'react'; import { mount } from 'enzyme'; import Lookup from '../../src/components/Lookup'; import { I18nProvider } from '@lingui/react'; const mockData = [{ name: 'foo', id: 0, isChecked: false }]; describe('', () => { test('initially renders succesfully', () => { mount( { }} data={mockData} /> ); }); test('calls "onLookup" when search icon is clicked', () => { const spy = jest.spyOn(Lookup.prototype, 'onLookup'); const wrapper = mount( { }} data={mockData} /> ); expect(spy).not.toHaveBeenCalled(); wrapper.find('#search').simulate('click'); expect(spy).toHaveBeenCalled(); }); });