From da0a87a7355a56c538ff9f0f60b385df96ecdd6e Mon Sep 17 00:00:00 2001 From: Alanna Scott Date: Wed, 14 Jun 2017 10:12:29 -0700 Subject: [PATCH] add test for ControlPanelSection (#2961) --- .../components/ControlPanelSection_spec.jsx | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 superset/assets/spec/javascripts/explore/components/ControlPanelSection_spec.jsx diff --git a/superset/assets/spec/javascripts/explore/components/ControlPanelSection_spec.jsx b/superset/assets/spec/javascripts/explore/components/ControlPanelSection_spec.jsx new file mode 100644 index 00000000000..05eac645729 --- /dev/null +++ b/superset/assets/spec/javascripts/explore/components/ControlPanelSection_spec.jsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { shallow } from 'enzyme'; +import { Panel } from 'react-bootstrap'; + +import InfoTooltipWithTrigger from + '../../../../javascripts/components/InfoTooltipWithTrigger'; + +import ControlPanelSection from + '../../../../javascripts/explore/components/ControlPanelSection'; + +const defaultProps = { + children:
a child element
, +}; + +const optionalProps = { + label: 'my label', + description: 'my description', + tooltip: 'my tooltip', +}; + +describe('ControlPanelSection', () => { + let wrapper; + let props; + it('is a valid element', () => { + expect( + React.isValidElement(), + ).to.equal(true); + }); + + it('renders a Panel component', () => { + wrapper = shallow(); + expect(wrapper.find(Panel)).to.have.length(1); + }); + + describe('with optional props', () => { + beforeEach(() => { + props = Object.assign(defaultProps, optionalProps); + wrapper = shallow(); + }); + + it('renders a label if present', () => { + expect(wrapper.find(Panel).dive().text()).to.contain('my label'); + }); + + it('renders a InfoTooltipWithTrigger if label and tooltip is present', () => { + expect(wrapper.find(Panel).dive().find(InfoTooltipWithTrigger)) + .to.have.length(1); + }); + }); +});