Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gix the bool rendering issues in React
  • Loading branch information
AllenFang committed May 16, 2018
commit f5a50db25f0ffe41d5ce2ad6db66f04a2e685dae
4 changes: 3 additions & 1 deletion packages/react-bootstrap-table2/src/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class Cell extends Component {
cellAttrs.onDoubleClick = this.handleEditingCell;
}
return (
<td { ...cellAttrs }>{ content }</td>
<td { ...cellAttrs }>
{ typeof content === 'boolean' ? `${content}` : content }
</td>
);
}
}
Expand Down
19 changes: 19 additions & 0 deletions packages/react-bootstrap-table2/test/cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ describe('Cell', () => {
});
});

describe('when content is bool value', () => {
const column = {
dataField: 'col1',
text: 'column 1'
};
const aRowWithBoolValue = { col1: true };

beforeEach(() => {
wrapper = shallow(
<Cell row={ aRowWithBoolValue } columnIndex={ 1 } rowIndex={ 1 } column={ column } />
);
});

it('should render successfully', () => {
expect(wrapper.length).toBe(1);
expect(wrapper.text()).toEqual(aRowWithBoolValue[column.dataField].toString());
});
});

describe('when column.formatter prop is defined', () => {
const rowIndex = 1;
const column = {
Expand Down