mirror of https://github.com/apache/superset.git
Add more tests to Filter spec (#2315)
This commit is contained in:
parent
422d1feb3e
commit
e817382efd
|
@ -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(<Filter {...props} />);
|
||||
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(<Filter {...props} />);
|
||||
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(<Filter {...props} />);
|
||||
expect(regexWrapper.find('input')).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue