Skip to content
This repository was archived by the owner on Oct 19, 2021. It is now read-only.

Commit e8097d1

Browse files
Ahsan Naveedjoshblack
authored andcommitted
feat(RadioTile): add className prop (#765)
* fix(RadioTile): Accepts className in props * fix(RadioTile): Update test * fix(RadioTile): Add default prop value for className * fix(RadioTile): Update test * fix(RadioTile): Add a test for custom className && code cleanup
1 parent a5fafb7 commit e8097d1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/RadioTile/RadioTile-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ describe('RadioButton', () => {
6464
wrapper.setProps({ labelText: 'test label text' });
6565
expect(label.text()).toMatch(/test label text/);
6666
});
67+
68+
it('should not have the className when no class is passed through props', () => {
69+
expect(label.hasClass(label.props.className)).toEqual(false);
70+
});
71+
72+
it('should have the className passed through props', () => {
73+
const label = render({
74+
className: 'extra-class',
75+
});
76+
expect(label.hasClass('extra-class')).toEqual(true);
77+
});
6778
});
6879

6980
describe('wrapper', () => {

src/components/RadioTile/RadioTile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import classNames from 'classnames';
77
export default class RadioTile extends React.Component {
88
static propTypes = {
99
checked: PropTypes.bool,
10+
className: PropTypes.string,
1011
defaultChecked: PropTypes.bool,
1112
id: PropTypes.string,
1213
name: PropTypes.string,
@@ -27,9 +28,9 @@ export default class RadioTile extends React.Component {
2728
};
2829

2930
render() {
30-
const { children, ...other } = this.props;
31+
const { children, className, ...other } = this.props;
3132

32-
const classes = classNames('bx--tile', 'bx--tile--selectable', {
33+
const classes = classNames(className, 'bx--tile', 'bx--tile--selectable', {
3334
'bx--tile--is-selected': this.props.checked,
3435
});
3536

0 commit comments

Comments
 (0)