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:
Evan Rusackas
2019-11-12 10:22:17 -08:00
committed by Maxime Beauchemin
parent a867d41d2a
commit 1b3e40feac
2 changed files with 14 additions and 1 deletions

View File

@@ -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);
});
});