mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Clickable checkbox labels (#8534)
* passing onClick prop to header with the existing onChange method. * basic test checking that label click fires the onChange method. * cleaning up stuff caught by linting.
This commit is contained in:
committed by
Maxime Beauchemin
parent
a867d41d2a
commit
1b3e40feac
@@ -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';
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@ export default class CheckboxControl extends React.Component {
|
||||
<ControlHeader
|
||||
{...this.props}
|
||||
leftNode={this.renderCheckbox()}
|
||||
onClick={this.onChange.bind(this)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user