Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion modules/__tests__/enhancer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var Enhancer = require('inject!enhancer.js')({
'./resolve-styles.js': resolveStyles
});

var {Component} = require('react');
var React = require('react/addons');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably be consistent and always require react/addons in tests, might help a bit with speed (just conjecture).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some crude testing it doesn't look like it makes much of a difference (if it does, it's very marginal), but we should do this for consistency's sake anyway - so here it is: #312

var {Component} = React;

describe('Enhancer', () => {
it('sets up initial state', () => {
Expand Down Expand Up @@ -153,4 +154,39 @@ describe('Enhancer', () => {
expect(mediaQueryListenersByQuery[key].remove).to.have.been.called;
});
});

it('manually populates static properties for IE <10', () => {
class Composed extends Component { }

Composed.defaultProps = { foo: 'bar' };

var Enhanced = Enhancer(Composed);

expect(Enhanced.defaultProps).to.deep.equal({ foo: 'bar' });
});

it('copies methods across to top level prototype', () => {
var Composed = React.createClass({

getStyles: function () {
return [{ color: 'black' }];
},

render: function () {
return (
<div style={this.getStyles()}>
Hello World!
</div>
);
}

});

var Enhanced = Enhancer(Composed);

Object.keys(Composed.prototype).forEach(key => {
expect(Enhanced.prototype.hasOwnProperty(key)).to.equal(true);
});
});

});