fix the bool rendering issues in React (#340) (#348)

This commit is contained in:
Allen 2018-05-23 22:42:46 +08:00 committed by GitHub
parent a50148fe85
commit fe2fd93c20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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>
);
}
}

View File

@ -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 = {