Skip to content

Commit

Permalink
Reformat no-did-mount-set-state and no-did-update-set-state tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 14, 2015
1 parent 7db2903 commit 0c3d542
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 118 deletions.
118 changes: 59 additions & 59 deletions tests/lib/rules/no-did-mount-set-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,64 @@ var ESLintTester = require('eslint-tester');
var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/no-did-mount-set-state', {

valid: [
{
code: '\
var Hello = React.createClass({\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}, {
code: '\
var Hello = React.createClass({\
componentDidMount: function() {},\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}, {
code: '\
var Hello = React.createClass({\
componentDidMount: function() {\
someNonMemberFunction(arg);\
this.someHandler = this.setState;\
},\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}
],
valid: [{
code: [
'var Hello = React.createClass({',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
'componentDidMount: function() {},',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
' componentDidMount: function() {',
' someNonMemberFunction(arg);',
' this.someHandler = this.setState;',
' },',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}],

invalid: [
{
code: '\
var Hello = React.createClass({\
componentDidMount: function() {\
this.setState({\
name: this.props.name.toUpperCase()\
});\
},\
render: function() {\
return <div>Hello {this.state.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
},
errors: [{
message: 'Do not use setState in componentDidMount'
}]
}
]
invalid: [{
code: [
'var Hello = React.createClass({',
' componentDidMount: function() {',
' this.setState({',
' name: this.props.name.toUpperCase()',
' });',
' },',
' render: function() {',
' return <div>Hello {this.state.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
},
errors: [{
message: 'Do not use setState in componentDidMount'
}]
}]
});
118 changes: 59 additions & 59 deletions tests/lib/rules/no-did-update-set-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,64 @@ var ESLintTester = require('eslint-tester');
var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/no-did-update-set-state', {

valid: [
{
code: '\
var Hello = React.createClass({\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}, {
code: '\
var Hello = React.createClass({\
componentDidUpdate: function() {},\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}, {
code: '\
var Hello = React.createClass({\
componentDidUpdate: function() {\
someNonMemberFunction(arg);\
this.someHandler = this.setState;\
},\
render: function() {\
return <div>Hello {this.props.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
}
}
],
valid: [{
code: [
'var Hello = React.createClass({',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
'componentDidUpdate: function() {},',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}, {
code: [
'var Hello = React.createClass({',
' componentDidUpdate: function() {',
' someNonMemberFunction(arg);',
' this.someHandler = this.setState;',
' },',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
}
}],

invalid: [
{
code: '\
var Hello = React.createClass({\
componentDidUpdate: function() {\
this.setState({\
name: this.props.name.toUpperCase()\
});\
},\
render: function() {\
return <div>Hello {this.state.name}</div>;\
}\
});',
ecmaFeatures: {
jsx: true
},
errors: [{
message: 'Do not use setState in componentDidUpdate'
}]
}
]
invalid: [{
code: [
'var Hello = React.createClass({',
' componentDidUpdate: function() {',
' this.setState({',
' name: this.props.name.toUpperCase()',
' });',
' },',
' render: function() {',
' return <div>Hello {this.state.name}</div>;',
' }',
'});'
].join('\n'),
ecmaFeatures: {
jsx: true
},
errors: [{
message: 'Do not use setState in componentDidUpdate'
}]
}]
});

0 comments on commit 0c3d542

Please sign in to comment.