mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
Added filter in ControlPanelsContainer for explore V2 (#1647)
* Added filter in ControlPanelsContainer * Move function for getting url params object to utils * Fixed python test * Move Filter to separate component * Added specs and made changes based on comments * Moved specs to right folder
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
import React from 'react';
|
||||
import Select from 'react-select';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import Filter from '../../../../javascripts/explorev2/components/Filter';
|
||||
|
||||
const defaultProps = {
|
||||
actions: {},
|
||||
filterColumnOpts: ['country_name'],
|
||||
filter: {
|
||||
id: 1,
|
||||
prefix: 'flt',
|
||||
col: 'country_name',
|
||||
eq: 'in',
|
||||
value: 'China',
|
||||
},
|
||||
prefix: 'flt',
|
||||
};
|
||||
|
||||
describe('Filter', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<Filter {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders Filters', () => {
|
||||
expect(
|
||||
React.isValidElement(<Filter {...defaultProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
|
||||
it('renders two select, one button and one input', () => {
|
||||
expect(wrapper.find(Select)).to.have.lengthOf(2);
|
||||
expect(wrapper.find(Button)).to.have.lengthOf(1);
|
||||
expect(wrapper.find('input')).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
import React from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Filters } from '../../../../javascripts/explorev2/components/Filters';
|
||||
import Filter from '../../../../javascripts/explorev2/components/Filter';
|
||||
|
||||
const defaultProps = {
|
||||
filterColumnOpts: ['country_name'],
|
||||
filters: [
|
||||
{
|
||||
id: 1,
|
||||
prefix: 'flt',
|
||||
col: 'country_name',
|
||||
eq: 'in',
|
||||
value: 'China',
|
||||
}],
|
||||
prefix: 'flt',
|
||||
};
|
||||
|
||||
describe('Filters', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<Filters {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders Filters', () => {
|
||||
expect(
|
||||
React.isValidElement(<Filters {...defaultProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
|
||||
it('renders one filter', () => {
|
||||
expect(wrapper.find(Filter)).to.have.lengthOf(1);
|
||||
expect(wrapper.find(Button)).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user