Skip to content

Commit f18b857

Browse files
committed
Rewrite no-string-refs tests with template literals
1 parent 31faa79 commit f18b857

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

tests/lib/rules/no-string-refs.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,70 +30,70 @@ const ruleTester = new RuleTester({parserOptions});
3030
ruleTester.run('no-refs', rule, {
3131

3232
valid: [{
33-
code: [
34-
'var Hello = createReactClass({',
35-
' componentDidMount: function() {',
36-
' var component = this.hello;',
37-
' },',
38-
' render: function() {',
39-
' return <div ref={c => this.hello = c}>Hello {this.props.name}</div>;',
40-
' }',
41-
'});'
42-
].join('\n'),
33+
code: `
34+
var Hello = createReactClass({
35+
componentDidMount: function() {
36+
var component = this.hello;
37+
},
38+
render: function() {
39+
return <div ref={c => this.hello = c}>Hello {this.props.name}</div>;
40+
}
41+
});
42+
`,
4343
parser: 'babel-eslint'
4444
}
4545
],
4646

4747
invalid: [{
48-
code: [
49-
'var Hello = createReactClass({',
50-
' componentDidMount: function() {',
51-
' var component = this.refs.hello;',
52-
' },',
53-
' render: function() {',
54-
' return <div>Hello {this.props.name}</div>;',
55-
' }',
56-
'});'
57-
].join('\n'),
48+
code: `
49+
var Hello = createReactClass({
50+
componentDidMount: function() {
51+
var component = this.refs.hello;
52+
},
53+
render: function() {
54+
return <div>Hello {this.props.name}</div>;
55+
}
56+
});
57+
`,
5858
parser: 'babel-eslint',
5959
errors: [{
6060
message: 'Using this.refs is deprecated.'
6161
}]
6262
}, {
63-
code: [
64-
'var Hello = createReactClass({',
65-
' render: function() {',
66-
' return <div ref="hello">Hello {this.props.name}</div>;',
67-
' }',
68-
'});'
69-
].join('\n'),
63+
code: `
64+
var Hello = createReactClass({
65+
render: function() {
66+
return <div ref="hello">Hello {this.props.name}</div>;
67+
}
68+
});
69+
`,
7070
parser: 'babel-eslint',
7171
errors: [{
7272
message: 'Using string literals in ref attributes is deprecated.'
7373
}]
7474
}, {
75-
code: [
76-
'var Hello = createReactClass({',
77-
' render: function() {',
78-
' return <div ref={\'hello\'}>Hello {this.props.name}</div>;',
79-
' }',
80-
'});'
81-
].join('\n'),
75+
code: `
76+
var Hello = createReactClass({
77+
render: function() {
78+
return <div ref={'hello'}>Hello {this.props.name}</div>;
79+
}
80+
});
81+
`,
8282
parser: 'babel-eslint',
8383
errors: [{
8484
message: 'Using string literals in ref attributes is deprecated.'
8585
}]
8686
}, {
87-
code: [
88-
'var Hello = createReactClass({',
89-
' componentDidMount: function() {',
90-
' var component = this.refs.hello;',
91-
' },',
92-
' render: function() {',
93-
' return <div ref="hello">Hello {this.props.name}</div>;',
94-
' }',
95-
'});'
96-
].join('\n'),
87+
code: `
88+
var Hello = createReactClass({
89+
componentDidMount: function() {
90+
var component = this.refs.hello;
91+
},
92+
render: function() {
93+
return <div ref="hello">Hello {this.props.name}</div>;
94+
}
95+
});
96+
`,
9797
parser: 'babel-eslint',
9898
errors: [{
9999
message: 'Using this.refs is deprecated.'

0 commit comments

Comments
 (0)