Skip to content

Commit 8ca344a

Browse files
committed
Rearranged tests to be at the bottom of componentWillReceiveProps tests. Added a default parser test.
1 parent 0fa0761 commit 8ca344a

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

tests/lib/rules/prop-types.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,10 +3071,10 @@ ruleTester.run('prop-types', rule, {
30713071
}, {
30723072
code: [
30733073
'class Hello extends Component {',
3074-
' static propTypes = forbidExtraProps({',
3074+
' static propTypes = {',
30753075
' bar: PropTypes.func',
3076-
' })',
3077-
' shouldComponentUpdate(nextProps) {',
3076+
' }',
3077+
' componentWillReceiveProps(nextProps) {',
30783078
' if (nextProps.foo) {',
30793079
' return;',
30803080
' }',
@@ -3085,9 +3085,6 @@ ruleTester.run('prop-types', rule, {
30853085
'}'
30863086
].join('\n'),
30873087
parser: 'babel-eslint',
3088-
settings: Object.assign({}, settings, {
3089-
propWrapperFunctions: ['forbidExtraProps']
3090-
}),
30913088
errors: [
30923089
{message: '\'foo\' is missing in props validation'}
30933090
]
@@ -3098,7 +3095,8 @@ ruleTester.run('prop-types', rule, {
30983095
' bar: PropTypes.func',
30993096
' }',
31003097
' componentWillReceiveProps(nextProps) {',
3101-
' if (nextProps.foo) {',
3098+
' const {foo} = nextProps;',
3099+
' if (foo) {',
31023100
' return;',
31033101
' }',
31043102
' }',
@@ -3117,8 +3115,7 @@ ruleTester.run('prop-types', rule, {
31173115
' static propTypes = {',
31183116
' bar: PropTypes.func',
31193117
' }',
3120-
' componentWillReceiveProps(nextProps) {',
3121-
' const {foo} = nextProps;',
3118+
' componentWillReceiveProps({foo}) {',
31223119
' if (foo) {',
31233120
' return;',
31243121
' }',
@@ -3135,9 +3132,6 @@ ruleTester.run('prop-types', rule, {
31353132
}, {
31363133
code: [
31373134
'class Hello extends Component {',
3138-
' static propTypes = {',
3139-
' bar: PropTypes.func',
3140-
' }',
31413135
' componentWillReceiveProps({foo}) {',
31423136
' if (foo) {',
31433137
' return;',
@@ -3146,16 +3140,41 @@ ruleTester.run('prop-types', rule, {
31463140
' render() {',
31473141
' return <div bar={this.props.bar} />;',
31483142
' }',
3143+
'}',
3144+
'Hello.propTypes = {',
3145+
' bar: PropTypes.func',
3146+
' }'
3147+
].join('\n'),
3148+
errors: [
3149+
{message: '\'foo\' is missing in props validation'}
3150+
]
3151+
}, {
3152+
code: [
3153+
'class Hello extends Component {',
3154+
' static propTypes = forbidExtraProps({',
3155+
' bar: PropTypes.func',
3156+
' })',
3157+
' shouldComponentUpdate(nextProps) {',
3158+
' if (nextProps.foo) {',
3159+
' return;',
3160+
' }',
3161+
' }',
3162+
' render() {',
3163+
' return <div bar={this.props.bar} />;',
3164+
' }',
31493165
'}'
31503166
].join('\n'),
31513167
parser: 'babel-eslint',
3168+
settings: Object.assign({}, settings, {
3169+
propWrapperFunctions: ['forbidExtraProps']
3170+
}),
31523171
errors: [
31533172
{message: '\'foo\' is missing in props validation'}
31543173
]
31553174
}, {
31563175
code: [
31573176
'class Hello extends Component {',
3158-
' componentWillReceiveProps({foo}) {',
3177+
' shouldComponentUpdate({foo}) {',
31593178
' if (foo) {',
31603179
' return;',
31613180
' }',

0 commit comments

Comments
 (0)