Skip to content

Commit 24658b5

Browse files
committed
Added more valid tests
1 parent b1444be commit 24658b5

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,19 @@ ruleTester.run('no-unused-prop-types', rule, {
12421242
'})'
12431243
].join('\n'),
12441244
parser: 'babel-eslint'
1245+
}, {
1246+
// Destructured props in componentWillReceiveProps shouldn't throw errors when used createReactClass, with default parser
1247+
code: [
1248+
'var Hello = createReactClass({',
1249+
' propTypes: {',
1250+
' something: PropTypes.bool,',
1251+
' },',
1252+
' componentWillReceiveProps (nextProps) {',
1253+
' const {something} = nextProps;',
1254+
' doSomething(something);',
1255+
' }',
1256+
'})'
1257+
].join('\n')
12451258
}, {
12461259
// Destructured function props in componentWillReceiveProps shouldn't throw errors
12471260
code: [
@@ -1268,6 +1281,18 @@ ruleTester.run('no-unused-prop-types', rule, {
12681281
'})'
12691282
].join('\n'),
12701283
parser: 'babel-eslint'
1284+
}, {
1285+
// Destructured function props in componentWillReceiveProps shouldn't throw errors when used createReactClass, with default parser
1286+
code: [
1287+
'var Hello = createReactClass({',
1288+
' propTypes: {',
1289+
' something: PropTypes.bool,',
1290+
' },',
1291+
' componentWillReceiveProps ({something}) {',
1292+
' doSomething(something);',
1293+
' }',
1294+
'})'
1295+
].join('\n')
12711296
}, {
12721297
// Destructured props in the constructor shouldn't throw errors
12731298
code: [
@@ -1325,6 +1350,19 @@ ruleTester.run('no-unused-prop-types', rule, {
13251350
'})'
13261351
].join('\n'),
13271352
parser: 'babel-eslint'
1353+
}, {
1354+
// Destructured props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
1355+
code: [
1356+
'var Hello = createReactClass({',
1357+
' propTypes: {',
1358+
' something: PropTypes.bool,',
1359+
' },',
1360+
' shouldComponentUpdate (nextProps, nextState) {',
1361+
' const {something} = nextProps;',
1362+
' return something;',
1363+
' }',
1364+
'})'
1365+
].join('\n')
13281366
}, {
13291367
// Destructured function props in the `shouldComponentUpdate` method shouldn't throw errors
13301368
code: [
@@ -1351,6 +1389,18 @@ ruleTester.run('no-unused-prop-types', rule, {
13511389
'})'
13521390
].join('\n'),
13531391
parser: 'babel-eslint'
1392+
}, {
1393+
// Destructured function props in `shouldComponentUpdate` shouldn't throw errors when used createReactClass, with default parser
1394+
code: [
1395+
'var Hello = createReactClass({',
1396+
' propTypes: {',
1397+
' something: PropTypes.bool,',
1398+
' },',
1399+
' shouldComponentUpdate ({something}, nextState) {',
1400+
' return something;',
1401+
' }',
1402+
'})'
1403+
].join('\n')
13541404
}, {
13551405
// Destructured props in the `componentWillUpdate` method shouldn't throw errors
13561406
code: [
@@ -1379,6 +1429,19 @@ ruleTester.run('no-unused-prop-types', rule, {
13791429
'})'
13801430
].join('\n'),
13811431
parser: 'babel-eslint'
1432+
}, {
1433+
// Destructured props in `componentWillUpdate` shouldn't throw errors when used createReactClass, with default parser
1434+
code: [
1435+
'var Hello = createReactClass({',
1436+
' propTypes: {',
1437+
' something: PropTypes.bool,',
1438+
' },',
1439+
' componentWillUpdate (nextProps, nextState) {',
1440+
' const {something} = nextProps;',
1441+
' return something;',
1442+
' }',
1443+
'})'
1444+
].join('\n')
13821445
}, {
13831446
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors
13841447
code: [
@@ -1405,6 +1468,18 @@ ruleTester.run('no-unused-prop-types', rule, {
14051468
'})'
14061469
].join('\n'),
14071470
parser: 'babel-eslint'
1471+
}, {
1472+
// Destructured function props in the `componentWillUpdate` method shouldn't throw errors when used createReactClass, with default parser
1473+
code: [
1474+
'var Hello = createReactClass({',
1475+
' propTypes: {',
1476+
' something: PropTypes.bool,',
1477+
' },',
1478+
' componentWillUpdate ({something}, nextState) {',
1479+
' return something;',
1480+
' }',
1481+
'})'
1482+
].join('\n')
14081483
}, {
14091484
// Destructured props in the `componentDidUpdate` method shouldn't throw errors
14101485
code: [
@@ -1433,6 +1508,19 @@ ruleTester.run('no-unused-prop-types', rule, {
14331508
'})'
14341509
].join('\n'),
14351510
parser: 'babel-eslint'
1511+
}, {
1512+
// Destructured props in `componentDidUpdate` shouldn't throw errors when used createReactClass, with default parser
1513+
code: [
1514+
'var Hello = createReactClass({',
1515+
' propTypes: {',
1516+
' something: PropTypes.bool,',
1517+
' },',
1518+
' componentDidUpdate (prevProps, prevState) {',
1519+
' const {something} = prevProps;',
1520+
' return something;',
1521+
' }',
1522+
'})'
1523+
].join('\n')
14361524
}, {
14371525
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors
14381526
code: [
@@ -1459,6 +1547,18 @@ ruleTester.run('no-unused-prop-types', rule, {
14591547
'})'
14601548
].join('\n'),
14611549
parser: 'babel-eslint'
1550+
}, {
1551+
// Destructured function props in the `componentDidUpdate` method shouldn't throw errors when used createReactClass, with default parser
1552+
code: [
1553+
'var Hello = createReactClass({',
1554+
' propTypes: {',
1555+
' something: PropTypes.bool,',
1556+
' },',
1557+
' componentDidUpdate ({something}, prevState) {',
1558+
' return something;',
1559+
' }',
1560+
'})'
1561+
].join('\n')
14621562
}, {
14631563
// Destructured state props in `componentDidUpdate` [Issue #825]
14641564
code: [

0 commit comments

Comments
 (0)