From 19ba336e32966a4643ac50c3c198fd806f858a74 Mon Sep 17 00:00:00 2001 From: Allen Date: Sat, 19 May 2018 13:07:57 +0800 Subject: [PATCH] gix the bool rendering issues in React (#340) --- packages/react-bootstrap-table2/src/cell.js | 4 +++- .../react-bootstrap-table2/test/cell.test.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/react-bootstrap-table2/src/cell.js b/packages/react-bootstrap-table2/src/cell.js index dc535a715..bfd61d5c8 100644 --- a/packages/react-bootstrap-table2/src/cell.js +++ b/packages/react-bootstrap-table2/src/cell.js @@ -88,7 +88,9 @@ class Cell extends Component { cellAttrs.onDoubleClick = this.handleEditingCell; } return ( - { content } + + { typeof content === 'boolean' ? `${content}` : content } + ); } } diff --git a/packages/react-bootstrap-table2/test/cell.test.js b/packages/react-bootstrap-table2/test/cell.test.js index 439a638b2..169524024 100644 --- a/packages/react-bootstrap-table2/test/cell.test.js +++ b/packages/react-bootstrap-table2/test/cell.test.js @@ -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( + + ); + }); + + 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 = {