Skip to content

Commit c615cb4

Browse files
committed
copy statics from ThemedComponent
1 parent 6e4d338 commit c615cb4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/components/themr.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
2121
}
2222

2323
static propTypes = {
24+
...ThemedComponent.propTypes,
2425
composeTheme: PropTypes.oneOf([ COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE ]),
2526
theme: PropTypes.object,
2627
themeNamespace: PropTypes.string
2728
}
2829

2930
static defaultProps = {
31+
...ThemedComponent.defaultProps,
3032
composeTheme: optionComposeTheme
3133
}
3234

test/components/themr.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,20 @@ describe('Themr decorator function', () => {
365365
const expectedTheme = { foo: 'foo_123 foo_567 foo_000' }
366366
expect(stub.props.theme).toEqual(expectedTheme)
367367
})
368+
369+
it('should copy statics from ThemedComponent', () => {
370+
const propTypes = {
371+
foo: PropTypes.array
372+
};
373+
const defaultProps = {
374+
foo: []
375+
};
376+
@themr('Foo')
377+
class Foo extends Component {
378+
static propTypes = propTypes;
379+
static defaultProps = defaultProps;
380+
}
381+
expect(Foo.propTypes.foo).toBe(propTypes.foo);
382+
expect(Foo.defaultProps.foo).toBe(defaultProps.foo);
383+
})
368384
})

0 commit comments

Comments
 (0)