Skip to content

Commit

Permalink
Rearranged tests to be at the bottom of componentWillReceiveProps tes…
Browse files Browse the repository at this point in the history
…ts. Added a default parser test.
  • Loading branch information
amerryma committed Feb 19, 2018
1 parent 0fa0761 commit 8ca344a
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3071,10 +3071,10 @@ ruleTester.run('prop-types', rule, {
}, {
code: [
'class Hello extends Component {',
' static propTypes = forbidExtraProps({',
' static propTypes = {',
' bar: PropTypes.func',
' })',
' shouldComponentUpdate(nextProps) {',
' }',
' componentWillReceiveProps(nextProps) {',
' if (nextProps.foo) {',
' return;',
' }',
Expand All @@ -3085,9 +3085,6 @@ ruleTester.run('prop-types', rule, {
'}'
].join('\n'),
parser: 'babel-eslint',
settings: Object.assign({}, settings, {
propWrapperFunctions: ['forbidExtraProps']
}),
errors: [
{message: '\'foo\' is missing in props validation'}
]
Expand All @@ -3098,7 +3095,8 @@ ruleTester.run('prop-types', rule, {
' bar: PropTypes.func',
' }',
' componentWillReceiveProps(nextProps) {',
' if (nextProps.foo) {',
' const {foo} = nextProps;',
' if (foo) {',
' return;',
' }',
' }',
Expand All @@ -3117,8 +3115,7 @@ ruleTester.run('prop-types', rule, {
' static propTypes = {',
' bar: PropTypes.func',
' }',
' componentWillReceiveProps(nextProps) {',
' const {foo} = nextProps;',
' componentWillReceiveProps({foo}) {',
' if (foo) {',
' return;',
' }',
Expand All @@ -3135,9 +3132,6 @@ ruleTester.run('prop-types', rule, {
}, {
code: [
'class Hello extends Component {',
' static propTypes = {',
' bar: PropTypes.func',
' }',
' componentWillReceiveProps({foo}) {',
' if (foo) {',
' return;',
Expand All @@ -3146,16 +3140,41 @@ ruleTester.run('prop-types', rule, {
' render() {',
' return <div bar={this.props.bar} />;',
' }',
'}',
'Hello.propTypes = {',
' bar: PropTypes.func',
' }'
].join('\n'),
errors: [
{message: '\'foo\' is missing in props validation'}
]
}, {
code: [
'class Hello extends Component {',
' static propTypes = forbidExtraProps({',
' bar: PropTypes.func',
' })',
' shouldComponentUpdate(nextProps) {',
' if (nextProps.foo) {',
' return;',
' }',
' }',
' render() {',
' return <div bar={this.props.bar} />;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint',
settings: Object.assign({}, settings, {
propWrapperFunctions: ['forbidExtraProps']
}),
errors: [
{message: '\'foo\' is missing in props validation'}
]
}, {
code: [
'class Hello extends Component {',
' componentWillReceiveProps({foo}) {',
' shouldComponentUpdate({foo}) {',
' if (foo) {',
' return;',
' }',
Expand Down

0 comments on commit 8ca344a

Please sign in to comment.