Skip to content

Commit

Permalink
Added more valid tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Feb 4, 2018
1 parent b1444be commit 24658b5
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -1242,6 +1242,19 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured props in componentWillReceiveProps shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentWillReceiveProps (nextProps) {',
' const {something} = nextProps;',
' doSomething(something);',
' }',
'})'
].join('\n')
}, {
// Destructured function props in componentWillReceiveProps shouldn't throw errors
code: [
Expand All @@ -1268,6 +1281,18 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured function props in componentWillReceiveProps shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentWillReceiveProps ({something}) {',
' doSomething(something);',
' }',
'})'
].join('\n')
}, {
// Destructured props in the constructor shouldn't throw errors
code: [
Expand Down Expand Up @@ -1325,6 +1350,19 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' shouldComponentUpdate (nextProps, nextState) {',
' const {something} = nextProps;',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
code: [
Expand All @@ -1351,6 +1389,18 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured function props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' shouldComponentUpdate ({something}, nextState) {',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured props in the `componentWillUpdate` method shouldn't throw errors
code: [
Expand Down Expand Up @@ -1379,6 +1429,19 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured props in `componentWillUpdate` shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentWillUpdate (nextProps, nextState) {',
' const {something} = nextProps;',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors
code: [
Expand All @@ -1405,6 +1468,18 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentWillUpdate ({something}, nextState) {',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured props in the `componentDidUpdate` method shouldn't throw errors
code: [
Expand Down Expand Up @@ -1433,6 +1508,19 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured props in `componentDidUpdate` shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentDidUpdate (prevProps, prevState) {',
' const {something} = prevProps;',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors
code: [
Expand All @@ -1459,6 +1547,18 @@ ruleTester.run('no-unused-prop-types', rule, {
'})'
].join('\n'),
parser: 'babel-eslint'
}, {
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors when used createReactClass, with default parser
code: [
'var Hello = createReactClass({',
' propTypes: {',
' something: PropTypes.bool,',
' },',
' componentDidUpdate ({something}, prevState) {',
' return something;',
' }',
'})'
].join('\n')
}, {
// Destructured state props in `componentDidUpdate` [Issue #825]
code: [
Expand Down

0 comments on commit 24658b5

Please sign in to comment.