Fixing label issue when columnType is null (#4700)

This commit is contained in:
michellethomas 2018-03-27 17:54:24 -07:00 committed by Grace Guo
parent d8d860facc
commit 485b0c275e
2 changed files with 20 additions and 3 deletions

View File

@ -24,7 +24,7 @@ export default function ColumnOption({ column, showType }) {
return (
<span>
{showType && <ColumnTypeLabel type={columnType} />}
{showType && columnType && <ColumnTypeLabel type={columnType} />}
<span className="m-r-5 option-label">
{column.verbose_name || column.column_name}
</span>

View File

@ -47,8 +47,14 @@ describe('ColumnOption', () => {
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));
wrapper = shallow(factory({
...props,
showType: true,
column: {
expression: null,
type: 'str',
},
}));
expect(wrapper.find(ColumnTypeLabel)).to.have.length(1);
});
it('column with expression has correct column label if showType is true', () => {
@ -57,6 +63,17 @@ describe('ColumnOption', () => {
expect(wrapper.find(ColumnTypeLabel)).to.have.length(1);
expect(wrapper.find(ColumnTypeLabel).props().type).to.equal('expression');
});
it('shows no column type label when type is null', () => {
wrapper = shallow(factory({
...props,
showType: true,
column: {
expression: null,
type: null,
},
}));
expect(wrapper.find(ColumnTypeLabel)).to.have.length(0);
});
it('dttm column has correct column label if showType is true', () => {
props.showType = true;
props.column.is_dttm = true;