2020-04-09 14:23:22 -05:00
|
|
|
import React from 'react';
|
|
|
|
import { QueryOperationAction } from './QueryOperationAction';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
|
|
|
|
describe('QueryOperationAction', () => {
|
|
|
|
it('renders', () => {
|
2020-04-16 06:49:58 -05:00
|
|
|
expect(() => shallow(<QueryOperationAction icon="panel-add" onClick={() => {}} />)).not.toThrow();
|
2020-04-09 14:23:22 -05:00
|
|
|
});
|
|
|
|
describe('when disabled', () => {
|
|
|
|
it('does not call onClick handler', () => {
|
|
|
|
const clickSpy = jest.fn();
|
2020-04-16 06:49:58 -05:00
|
|
|
const wrapper = shallow(<QueryOperationAction icon="panel-add" onClick={clickSpy} title="Test action" />);
|
2020-04-09 14:23:22 -05:00
|
|
|
const actionEl = wrapper.find({ 'aria-label': 'Test action query operation action' });
|
|
|
|
|
|
|
|
expect(actionEl).toHaveLength(1);
|
|
|
|
expect(clickSpy).not.toBeCalled();
|
|
|
|
|
|
|
|
actionEl.first().simulate('click');
|
|
|
|
|
|
|
|
expect(clickSpy).toBeCalledTimes(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|