Skip to content

Commit

Permalink
Merge pull request #17 from materialr/feature/extra-props
Browse files Browse the repository at this point in the history
feat: add extra props that are passed in
  • Loading branch information
hvolschenk committed May 18, 2018
2 parents ca1b93c + 9e07b27 commit ffaecb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,19 @@ class Button extends React.Component {
render() {
const {
getClassNames,
props: { children, disabled, onClick, type },
props: {
children,
className,
dense,
disabled,
onClick,
outlined,
raised,
ripple,
type,
unelevated,
...props
},
} = this;
return (
<button
Expand All @@ -62,6 +74,7 @@ class Button extends React.Component {
onClick={onClick}
ref={(elementRoot) => { this.elementRoot = elementRoot; }}
type={type}
{...props}
>
{children}
</button>
Expand Down
13 changes: 13 additions & 0 deletions src/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,16 @@ test('Makes no change when the ripple prop doesn\'t change', () => {
expect(actualDestroy).toBe(expectedDestroy);
expect(actualMDCRipple).toBe(expectedMDCRipple);
});

test('Adds extra properties that are passed in', () => {
const DATA_QA = 'DATA_QA';
const wrapper = shallow(
<Button data-qa={DATA_QA}>{CHILDREN}</Button>,
{ disableLifecycleMethods: true },
);
const expected = DATA_QA;

const actual = wrapper.props()['data-qa'];

expect(actual).toBe(expected);
});

0 comments on commit ffaecb2

Please sign in to comment.