test: Adds tests to the filter scope components (#13887)

This commit is contained in:
Michael S. Molina
2021-04-07 01:31:35 -03:00
committed by GitHub
parent 3b11654c5a
commit 4602ead10c
11 changed files with 465 additions and 79 deletions

View File

@@ -19,8 +19,8 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import sinon from 'sinon';
import { shallow, mount } from 'enzyme';
import { mount } from 'enzyme';
import { ThemeProvider, supersetTheme } from '@superset-ui/core';
import CheckboxControl from 'src/explore/components/controls/CheckboxControl';
import ControlHeader from 'src/explore/components/ControlHeader';
import Checkbox from 'src/components/Checkbox';
@@ -36,20 +36,21 @@ describe('CheckboxControl', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<CheckboxControl {...defaultProps} />);
wrapper = mount(
<ThemeProvider theme={supersetTheme}>
<CheckboxControl {...defaultProps} />
</ThemeProvider>,
);
});
it('renders a Checkbox', () => {
const controlHeader = wrapper.find(ControlHeader);
const controlHeader = wrapper.childAt(0).find(ControlHeader);
expect(controlHeader).toHaveLength(1);
const headerWrapper = controlHeader.shallow();
expect(headerWrapper.find(Checkbox)).toHaveLength(1);
expect(controlHeader.find(Checkbox)).toHaveLength(1);
});
it('Checks the box when the label is clicked', () => {
const fullComponent = mount(<CheckboxControl {...defaultProps} />);
const fullComponent = wrapper.childAt(0);
const spy = sinon.spy(fullComponent.instance(), 'onChange');
fullComponent.instance().forceUpdate();