Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';

import CheckboxControl from '../../../../src/explore/components/controls/CheckboxControl';
import ControlHeader from '../../../../src/explore/components/ControlHeader';
Expand All @@ -46,4 +46,16 @@ describe('CheckboxControl', () => {
const headerWrapper = controlHeader.shallow();
expect(headerWrapper.find(Checkbox)).toHaveLength(1);
});

it('Checks the box when the label is clicked', () => {
const fullComponent = mount(<CheckboxControl {...defaultProps} />);

const spy = sinon.spy(fullComponent.instance(), 'onChange');

fullComponent.instance().forceUpdate();

fullComponent.find('label span').last().simulate('click');

expect(spy.calledOnce).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class CheckboxControl extends React.Component {
<ControlHeader
{...this.props}
leftNode={this.renderCheckbox()}
onClick={this.onChange.bind(this)}
/>
);
}
Expand Down