Skip to content

Commit

Permalink
Fixing label issue when columnType is null (apache#4700)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellethomas committed May 23, 2018
1 parent aa66da7 commit 3fb3cc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/assets/javascripts/components/ColumnOption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
21 changes: 19 additions & 2 deletions superset/assets/spec/javascripts/components/ColumnOption_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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;
Expand Down

0 comments on commit 3fb3cc5

Please sign in to comment.