From bca3c88dc2b1941c2761db86b04ad49ced08c342 Mon Sep 17 00:00:00 2001 From: Diana Suvorova Date: Fri, 28 Jul 2017 12:57:47 -0700 Subject: [PATCH] adding test cases from #811 --- tests/lib/rules/no-unused-prop-types.js | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index f52371766a..9a98ebd05b 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -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 (', + '
', + ' ', + '
', + ' );', + '}', + '});' + ].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
{this.message}
;', + '}', + '}' + ].join('\n'), + parser: 'babel-eslint' } ],