Skip to content

Commit 243df3d

Browse files
authored
Merge pull request javivelasco#18 from raveclassic/copy_statics
Copy statics
2 parents be0c33b + 7828d5a commit 243df3d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
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: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ describe('Themr decorator function', () => {
248248
})
249249

250250
it('throws an error if an invalid composition option passed', () => {
251-
expect(() => (
251+
expect(() => {
252252
@themr('Container', null, { composeTheme: 'foo' })
253-
class Container extends Component {
253+
class Container extends Component { //eslint-disable-line no-unused-vars
254254
render() {
255255
return <Passthrough {...this.props} />
256256
}
257257
}
258-
)).toThrow(/composeTheme/)
258+
}).toThrow(/composeTheme/)
259259
})
260260

261261
it('works properly when no theme is provided', () => {
@@ -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)