diff --git a/superset/assets/spec/javascripts/explorev2/components/Filter_spec.js b/superset/assets/spec/javascripts/explorev2/components/Filter_spec.js index b1425d8fd9f8c..b21efe2ed2a71 100644 --- a/superset/assets/spec/javascripts/explorev2/components/Filter_spec.js +++ b/superset/assets/spec/javascripts/explorev2/components/Filter_spec.js @@ -11,7 +11,6 @@ import SelectControl from '../../../../javascripts/explorev2/components/controls const defaultProps = { choices: ['country_name'], - opChoices: ['in', 'not in'], changeFilter: sinon.spy(), removeFilter: () => { // noop @@ -19,7 +18,7 @@ const defaultProps = { filter: { col: null, op: 'in', - value: '', + value: ['val'], }, datasource: { id: 1, @@ -45,6 +44,25 @@ describe('Filter', () => { expect(wrapper.find(Select)).to.have.lengthOf(2); expect(wrapper.find(Button)).to.have.lengthOf(1); expect(wrapper.find(SelectControl)).to.have.lengthOf(1); + expect(wrapper.find('#select-op').prop('options')).to.have.lengthOf(2); + }); + + it('renders five op choices for table datasource', () => { + const props = defaultProps; + props.datasource = { + id: 1, + type: 'druid', + filter_select: false, + }; + const druidWrapper = shallow(); + expect(druidWrapper.find('#select-op').prop('options')).to.have.lengthOf(5); + }); + + it('renders six op choices for having filter', () => { + const props = defaultProps; + props.having = true; + const havingWrapper = shallow(); + expect(havingWrapper.find('#select-op').prop('options')).to.have.lengthOf(6); }); it('calls changeFilter when select is changed', () => { @@ -56,4 +74,15 @@ describe('Filter', () => { selectVal.simulate('change', { value: 'x' }); expect(defaultProps.changeFilter).to.have.property('callCount', 3); }); + + it('renders input for regex filters', () => { + const props = defaultProps; + props.filter = { + col: null, + op: 'regex', + value: 'val', + }; + const regexWrapper = shallow(); + expect(regexWrapper.find('input')).to.have.lengthOf(1); + }); });