1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00
awx/__tests__/components/AnsibleSelect.test.jsx
kialam 9627a73978
Rename AnsibleEnvironmentSelect to AnsibleSelect
- Update references to the component.
2018-12-11 16:42:24 -05:00

19 lines
812 B
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import AnsibleSelect from '../../src/components/AnsibleSelect';
const mockData = ['foo', 'bar'];
describe('<AnsibleSelect />', () => {
test('initially renders succesfully', async() => {
const wrapper = mount(<AnsibleSelect selected="foo" data={mockData} selectChange={() => {}} />);
wrapper.setState({ isHidden: false });
});
test('calls "onSelectChange" on dropdown select change', () => {
const spy = jest.spyOn(AnsibleSelect.prototype, 'onSelectChange');
const wrapper = mount(<AnsibleSelect selected="foo" data={mockData} selectChange={() => {}} />);
wrapper.setState({ isHidden: false });
expect(spy).not.toHaveBeenCalled();
wrapper.find('select').simulate('change');
expect(spy).toHaveBeenCalled();
});
});