mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
Renaming field to control (#2210)
This commit is contained in:
committed by
GitHub
parent
d5ba88b407
commit
1e47d6fb41
@@ -5,14 +5,14 @@ import { defaultState } from '../../../javascripts/explorev2/stores/store';
|
||||
import { exploreReducer } from '../../../javascripts/explorev2/reducers/exploreReducer';
|
||||
|
||||
describe('reducers', () => {
|
||||
it('sets correct field value given a key and value', () => {
|
||||
it('sets correct control value given a key and value', () => {
|
||||
const newState = exploreReducer(
|
||||
defaultState, actions.setFieldValue('x_axis_label', 'x', []));
|
||||
expect(newState.fields.x_axis_label.value).to.equal('x');
|
||||
defaultState, actions.setControlValue('x_axis_label', 'x', []));
|
||||
expect(newState.controls.x_axis_label.value).to.equal('x');
|
||||
});
|
||||
it('setFieldValue works as expected with a checkbox', () => {
|
||||
it('setControlValue works as expected with a checkbox', () => {
|
||||
const newState = exploreReducer(defaultState,
|
||||
actions.setFieldValue('show_legend', true, []));
|
||||
expect(newState.fields.show_legend.value).to.equal(true);
|
||||
actions.setControlValue('show_legend', true, []));
|
||||
expect(newState.controls.show_legend.value).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,18 +5,18 @@ import sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import CheckboxField from '../../../../javascripts/explorev2/components/CheckboxField';
|
||||
import CheckboxControl from '../../../../javascripts/explorev2/components/controls/CheckboxControl';
|
||||
|
||||
const defaultProps = {
|
||||
name: 'show_legend',
|
||||
onChange: sinon.spy(),
|
||||
};
|
||||
|
||||
describe('CheckboxField', () => {
|
||||
describe('CheckboxControl', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<CheckboxField {...defaultProps} />);
|
||||
wrapper = shallow(<CheckboxControl {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders a Checkbox', () => {
|
||||
@@ -3,7 +3,7 @@ import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Panel } from 'react-bootstrap';
|
||||
import { getFormDataFromFields, defaultFields }
|
||||
import { getFormDataFromControls, defaultControls }
|
||||
from '../../../../javascripts/explorev2/stores/store';
|
||||
import {
|
||||
ControlPanelsContainer,
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
const defaultProps = {
|
||||
datasource_type: 'table',
|
||||
actions: {},
|
||||
fields: defaultFields,
|
||||
form_data: getFormDataFromFields(defaultFields),
|
||||
controls: defaultControls,
|
||||
form_data: getFormDataFromControls(defaultControls),
|
||||
isDatasourceMetaLoading: false,
|
||||
exploreState: {},
|
||||
};
|
||||
|
||||
@@ -2,16 +2,16 @@ import React from 'react';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import FieldSetRow from '../../../../javascripts/explorev2/components/FieldSetRow';
|
||||
import ControlSetRow from '../../../../javascripts/explorev2/components/ControlRow';
|
||||
|
||||
describe('FieldSetRow', () => {
|
||||
describe('ControlSetRow', () => {
|
||||
it('renders a single row with one element', () => {
|
||||
const wrapper = shallow(<FieldSetRow fields={[<a />]} />);
|
||||
const wrapper = shallow(<ControlSetRow controls={[<a />]} />);
|
||||
expect(wrapper.find('.row')).to.have.lengthOf(1);
|
||||
expect(wrapper.find('.row').find('a')).to.have.lengthOf(1);
|
||||
});
|
||||
it('renders a single row with two elements', () => {
|
||||
const wrapper = shallow(<FieldSetRow fields={[<a />, <a />]} />);
|
||||
const wrapper = shallow(<ControlSetRow controls={[<a />, <a />]} />);
|
||||
expect(wrapper.find('.row')).to.have.lengthOf(1);
|
||||
expect(wrapper.find('.row').find('a')).to.have.lengthOf(2);
|
||||
});
|
||||
@@ -5,8 +5,8 @@ import sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import FilterField from '../../../../javascripts/explorev2/components/FilterField';
|
||||
import Filter from '../../../../javascripts/explorev2/components/Filter';
|
||||
import FilterControl from '../../../../javascripts/explorev2/components/controls/FilterControl';
|
||||
import Filter from '../../../../javascripts/explorev2/components/controls/Filter';
|
||||
|
||||
const defaultProps = {
|
||||
choices: ['country_name'],
|
||||
@@ -20,16 +20,16 @@ const defaultProps = {
|
||||
},
|
||||
};
|
||||
|
||||
describe('FilterField', () => {
|
||||
describe('FilterControl', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<FilterField {...defaultProps} />);
|
||||
wrapper = shallow(<FilterControl {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders Filters', () => {
|
||||
expect(
|
||||
React.isValidElement(<FilterField {...defaultProps} />)
|
||||
React.isValidElement(<FilterControl {...defaultProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
|
||||
@@ -6,8 +6,8 @@ import sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import Filter from '../../../../javascripts/explorev2/components/Filter';
|
||||
import SelectField from '../../../../javascripts/explorev2/components/SelectField';
|
||||
import Filter from '../../../../javascripts/explorev2/components/controls/Filter';
|
||||
import SelectControl from '../../../../javascripts/explorev2/components/controls/SelectControl';
|
||||
|
||||
const defaultProps = {
|
||||
choices: ['country_name'],
|
||||
@@ -44,7 +44,7 @@ describe('Filter', () => {
|
||||
it('renders two selects, one button and one input', () => {
|
||||
expect(wrapper.find(Select)).to.have.lengthOf(2);
|
||||
expect(wrapper.find(Button)).to.have.lengthOf(1);
|
||||
expect(wrapper.find(SelectField)).to.have.lengthOf(1);
|
||||
expect(wrapper.find(SelectControl)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('calls changeFilter when select is changed', () => {
|
||||
@@ -52,7 +52,7 @@ describe('Filter', () => {
|
||||
selectCol.simulate('change', { value: 'col' });
|
||||
const selectOp = wrapper.find('#select-op');
|
||||
selectOp.simulate('change', { value: 'in' });
|
||||
const selectVal = wrapper.find(SelectField);
|
||||
const selectVal = wrapper.find(SelectControl);
|
||||
selectVal.simulate('change', { value: 'x' });
|
||||
expect(defaultProps.changeFilter).to.have.property('callCount', 3);
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import SelectField from '../../../../javascripts/explorev2/components/SelectField';
|
||||
import SelectControl from '../../../../javascripts/explorev2/components/controls/SelectControl';
|
||||
|
||||
const defaultProps = {
|
||||
choices: [[10, 10], [20, 20]],
|
||||
@@ -14,11 +14,11 @@ const defaultProps = {
|
||||
onChange: sinon.spy(),
|
||||
};
|
||||
|
||||
describe('SelectField', () => {
|
||||
describe('SelectControl', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SelectField {...defaultProps} />);
|
||||
wrapper = shallow(<SelectControl {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders a Select', () => {
|
||||
@@ -32,7 +32,7 @@ describe('SelectField', () => {
|
||||
});
|
||||
|
||||
it('renders a Creatable for freeform', () => {
|
||||
wrapper = shallow(<SelectField {...defaultProps} freeForm />);
|
||||
wrapper = shallow(<SelectControl {...defaultProps} freeForm />);
|
||||
expect(wrapper.find(Creatable)).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,7 @@ import sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, beforeEach } from 'mocha';
|
||||
import { shallow } from 'enzyme';
|
||||
import TextAreaField from '../../../../javascripts/explorev2/components/TextAreaField';
|
||||
import TextAreaControl from '../../../../javascripts/explorev2/components/controls/TextAreaControl';
|
||||
|
||||
const defaultProps = {
|
||||
name: 'x_axis_label',
|
||||
@@ -13,11 +13,11 @@ const defaultProps = {
|
||||
onChange: sinon.spy(),
|
||||
};
|
||||
|
||||
describe('SelectField', () => {
|
||||
describe('SelectControl', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<TextAreaField {...defaultProps} />);
|
||||
wrapper = shallow(<TextAreaControl {...defaultProps} />);
|
||||
});
|
||||
|
||||
it('renders a FormControl', () => {
|
||||
|
||||
Reference in New Issue
Block a user