Adding column type label to dropdowns (#4566)

* Adding column type label to dropdowns

* Changing the style of column type label

* Adding tests for ColumnTypeLabel

* Adding tests for time and fixing if statement order

* Changing location of ColumnTypeLabel tests

* Updating ColumnTypeLabel structure
This commit is contained in:
michellethomas
2018-03-16 14:19:09 -07:00
committed by Chris Williams
parent 6875868cf6
commit 3f1dfb3173
9 changed files with 155 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import { describe, it } from 'mocha';
import { shallow } from 'enzyme';
import ColumnOption from '../../../javascripts/components/ColumnOption';
import ColumnTypeLabel from '../../../javascripts/components/ColumnTypeLabel';
import InfoTooltipWithTrigger from '../../../javascripts/components/InfoTooltipWithTrigger';
describe('ColumnOption', () => {
@@ -14,6 +15,7 @@ describe('ColumnOption', () => {
expression: 'SUM(foo)',
description: 'Foo is the greatest column of all',
},
showType: false,
};
let wrapper;
@@ -44,4 +46,22 @@ describe('ColumnOption', () => {
wrapper = shallow(factory(props));
expect(wrapper.find('.option-label').first().text()).to.equal('foo');
});
it('shows a column type label when showType is true', () => {
props.showType = true;
wrapper = shallow(factory(props));
expect(wrapper.find(ColumnTypeLabel)).to.have.length(1);
});
it('column with expression has correct column label if showType is true', () => {
props.showType = true;
wrapper = shallow(factory(props));
expect(wrapper.find(ColumnTypeLabel)).to.have.length(1);
expect(wrapper.find(ColumnTypeLabel).props().type).to.equal('expression');
});
it('dttm column has correct column label if showType is true', () => {
props.showType = true;
props.column.is_dttm = true;
wrapper = shallow(factory(props));
expect(wrapper.find(ColumnTypeLabel)).to.have.length(1);
expect(wrapper.find(ColumnTypeLabel).props().type).to.equal('time');
});
});