mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 11:10:03 -03:30
Fix & Add unit tests.
This commit is contained in:
33
__tests__/components/Lookup.test.jsx
Normal file
33
__tests__/components/Lookup.test.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
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('<Lookup />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
<Lookup
|
||||
lookup_header="Foo Bar"
|
||||
lookupChange={() => { }}
|
||||
data={mockData}
|
||||
/>
|
||||
);
|
||||
});
|
||||
test('calls "onLookup" when search icon is clicked', () => {
|
||||
const spy = jest.spyOn(Lookup.prototype, 'onLookup');
|
||||
const wrapper = mount(
|
||||
<I18nProvider>
|
||||
<Lookup
|
||||
lookup_header="Foo Bar"
|
||||
lookupChange={() => { }}
|
||||
data={mockData}
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
wrapper.find('#search').simulate('click');
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user