Skip to content

Commit a1de7fa

Browse files
committed
Rewrite no-is-mounted tests with template literals
1 parent f6a91f3 commit a1de7fa

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

tests/lib/rules/no-is-mounted.js

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,77 +28,77 @@ const ruleTester = new RuleTester({parserOptions});
2828
ruleTester.run('no-is-mounted', rule, {
2929

3030
valid: [{
31-
code: [
32-
'var Hello = function() {',
33-
'};'
34-
].join('\n')
31+
code: `
32+
var Hello = function() {
33+
};
34+
`
3535
}, {
36-
code: [
37-
'var Hello = createReactClass({',
38-
' render: function() {',
39-
' return <div>Hello</div>;',
40-
' }',
41-
'});'
42-
].join('\n')
36+
code: `
37+
var Hello = createReactClass({
38+
render: function() {
39+
return <div>Hello</div>;
40+
}
41+
});
42+
`
4343
}, {
44-
code: [
45-
'var Hello = createReactClass({',
46-
' componentDidUpdate: function() {',
47-
' someNonMemberFunction(arg);',
48-
' this.someFunc = this.isMounted;',
49-
' },',
50-
' render: function() {',
51-
' return <div>Hello</div>;',
52-
' }',
53-
'});'
54-
].join('\n')
44+
code: `
45+
var Hello = createReactClass({
46+
componentDidUpdate: function() {
47+
someNonMemberFunction(arg);
48+
this.someFunc = this.isMounted;
49+
},
50+
render: function() {
51+
return <div>Hello</div>;
52+
}
53+
});
54+
`
5555
}],
5656

5757
invalid: [{
58-
code: [
59-
'var Hello = createReactClass({',
60-
' componentDidUpdate: function() {',
61-
' if (!this.isMounted()) {',
62-
' return;',
63-
' }',
64-
' },',
65-
' render: function() {',
66-
' return <div>Hello</div>;',
67-
' }',
68-
'});'
69-
].join('\n'),
58+
code: `
59+
var Hello = createReactClass({
60+
componentDidUpdate: function() {
61+
if (!this.isMounted()) {
62+
return;
63+
}
64+
},
65+
render: function() {
66+
return <div>Hello</div>;
67+
}
68+
});
69+
`,
7070
errors: [{
7171
message: 'Do not use isMounted'
7272
}]
7373
}, {
74-
code: [
75-
'var Hello = createReactClass({',
76-
' someMethod: function() {',
77-
' if (!this.isMounted()) {',
78-
' return;',
79-
' }',
80-
' },',
81-
' render: function() {',
82-
' return <div onClick={this.someMethod.bind(this)}>Hello</div>;',
83-
' }',
84-
'});'
85-
].join('\n'),
74+
code: `
75+
var Hello = createReactClass({
76+
someMethod: function() {
77+
if (!this.isMounted()) {
78+
return;
79+
}
80+
},
81+
render: function() {
82+
return <div onClick={this.someMethod.bind(this)}>Hello</div>;
83+
}
84+
});
85+
`,
8686
errors: [{
8787
message: 'Do not use isMounted'
8888
}]
8989
}, {
90-
code: [
91-
'class Hello extends React.Component {',
92-
' someMethod() {',
93-
' if (!this.isMounted()) {',
94-
' return;',
95-
' }',
96-
' }',
97-
' render() {',
98-
' return <div onClick={this.someMethod.bind(this)}>Hello</div>;',
99-
' }',
100-
'};'
101-
].join('\n'),
90+
code: `
91+
class Hello extends React.Component {
92+
someMethod() {
93+
if (!this.isMounted()) {
94+
return;
95+
}
96+
}
97+
render() {
98+
return <div onClick={this.someMethod.bind(this)}>Hello</div>;
99+
}
100+
};
101+
`,
102102
errors: [{
103103
message: 'Do not use isMounted'
104104
}]

0 commit comments

Comments
 (0)