Skip to content

Commit

Permalink
adding test cases from #811
Browse files Browse the repository at this point in the history
  • Loading branch information
DianaSuvorova authored and ljharb committed Jul 29, 2017
1 parent bd23406 commit bca3c88
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,49 @@ ruleTester.run('no-unused-prop-types', rule, {
' property2: React.propTypes.string.isRequired',
'}'
].join('\n')
}, {
// issue 811
code: [
'const Button = React.createClass({',
'displayName: "Button",',

'propTypes: {',
' name: React.PropTypes.string.isRequired,',
' isEnabled: React.PropTypes.bool.isRequired',
'},',

'render() {',
' const item = this.props;',
' const disabled = !this.props.isEnabled;',
' return (',
' <div>',
' <button type="button" disabled={disabled}>{item.name}</button>',
' </div>',
' );',
'}',
'});'
].join('\n')
}, {
// issue 811
code: [
'class Foo extends React.Component {',
' static propTypes = {',
' foo: PropTypes.func.isRequired,',
'}',

'constructor(props) {',
' super(props);',

' const { foo } = props;',
' this.message = foo("blablabla");',
'}',

'render() {',
' return <div>{this.message}</div>;',
'}',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit bca3c88

Please sign in to comment.