Skip to content

Commit

Permalink
Merge pull request #21 from inian/master
Browse files Browse the repository at this point in the history
changing withStyles to be a decorator
  • Loading branch information
koistya committed Mar 14, 2016
2 parents 5e4b062 + 60aa234 commit 506718c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/withStyles.js
Expand Up @@ -13,8 +13,8 @@ function getDisplayName(ComposedComponent) {
return ComposedComponent.displayName || ComposedComponent.name || 'Component';
}

function withStyles(ComposedComponent, ...styles) {
return class WithStyles extends Component {
function withStyles(...styles) {
return (ComposedComponent) => class WithStyles extends Component {
static contextTypes = {
insertCss: PropTypes.func.isRequired,
};
Expand Down
8 changes: 4 additions & 4 deletions test/withStylesSpec.js
Expand Up @@ -11,15 +11,15 @@ describe('withStyles(ComposedComponent, ...styles)', () => {
}

it('Should set the displayName correctly', () => {
expect(withStyles(
expect(withStyles('')(
class Foo extends Component {
render() {
return <div />;
}
}
).displayName).to.equal('WithStyles(Foo)');

expect(withStyles(
expect(withStyles('')(
createClass({
displayName: 'Bar',
render() {
Expand All @@ -28,7 +28,7 @@ describe('withStyles(ComposedComponent, ...styles)', () => {
})
).displayName).to.equal('WithStyles(Bar)');

expect(withStyles(
expect(withStyles('')(
createClass({
render() {
return <div />;
Expand All @@ -44,7 +44,7 @@ describe('withStyles(ComposedComponent, ...styles)', () => {
}
}

const decorated = withStyles(Container);
const decorated = withStyles('')(Container);
expect(decorated.ComposedComponent).to.equal(Container);
});
});

0 comments on commit 506718c

Please sign in to comment.