Skip to content

Commit f6a91f3

Browse files
committed
Rewrite no-redundant-scu tests with template literals
1 parent 04c0d5f commit f6a91f3

File tree

1 file changed

+77
-76
lines changed

1 file changed

+77
-76
lines changed

tests/lib/rules/no-redundant-should-component-update.js

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -31,118 +31,119 @@ const ruleTester = new RuleTester();
3131
ruleTester.run('no-redundant-should-component-update', rule, {
3232
valid: [
3333
{
34-
code: [
35-
'class Foo extends React.Component {',
36-
' shouldComponentUpdate() {',
37-
' return true;',
38-
' }',
39-
'}'
40-
].join('\n'),
34+
code: `
35+
class Foo extends React.Component {
36+
shouldComponentUpdate() {
37+
return true;
38+
}
39+
}
40+
`,
4141
parserOptions: parserOptions
4242
},
4343
{
44-
code: [
45-
'class Foo extends React.Component {',
46-
' shouldComponentUpdate = () => {',
47-
' return true;',
48-
' }',
49-
'}'
50-
].join('\n'),
44+
code: `
45+
class Foo extends React.Component {
46+
shouldComponentUpdate = () => {
47+
return true;
48+
}
49+
}
50+
`,
5151
parser: 'babel-eslint',
5252
parserOptions: parserOptions
5353
},
5454
{
55-
code: [
56-
'class Foo extends React.Component {',
57-
' shouldComponentUpdate() {',
58-
' return true;',
59-
' }',
60-
'}'
61-
].join('\n'),
55+
code: `
56+
class Foo extends React.Component {
57+
shouldComponentUpdate() {
58+
return true;
59+
}
60+
}
61+
`,
6262
parserOptions: parserOptions
6363
},
6464
{
65-
code: [
66-
'function Foo() {',
67-
' return class Bar extends React.Component {',
68-
' shouldComponentUpdate() {',
69-
' return true;',
70-
' }',
71-
' };',
72-
'}'
73-
].join('\n'),
65+
code: `
66+
function Foo() {
67+
return class Bar extends React.Component {
68+
shouldComponentUpdate() {
69+
return true;
70+
}
71+
};
72+
}
73+
`,
7474
parserOptions: parserOptions
7575
}
7676
],
77+
7778
invalid: [
7879
{
79-
code: [
80-
'class Foo extends React.PureComponent {',
81-
' shouldComponentUpdate() {',
82-
' return true;',
83-
' }',
84-
'}'
85-
].join('\n'),
80+
code: `
81+
class Foo extends React.PureComponent {
82+
shouldComponentUpdate() {
83+
return true;
84+
}
85+
}
86+
`,
8687
errors: [{message: errorMessage('Foo')}],
8788
parserOptions: parserOptions
8889
},
8990
{
90-
code: [
91-
'class Foo extends PureComponent {',
92-
' shouldComponentUpdate() {',
93-
' return true;',
94-
' }',
95-
'}'
96-
].join('\n'),
91+
code: `
92+
class Foo extends PureComponent {
93+
shouldComponentUpdate() {
94+
return true;
95+
}
96+
}
97+
`,
9798
errors: [{message: errorMessage('Foo')}],
9899
parserOptions: parserOptions
99100
},
100101
{
101-
code: [
102-
'class Foo extends React.PureComponent {',
103-
' shouldComponentUpdate = () => {',
104-
' return true;',
105-
' }',
106-
'}'
107-
].join('\n'),
102+
code: `
103+
class Foo extends React.PureComponent {
104+
shouldComponentUpdate = () => {
105+
return true;
106+
}
107+
}
108+
`,
108109
errors: [{message: errorMessage('Foo')}],
109110
parser: 'babel-eslint',
110111
parserOptions: parserOptions
111112
},
112113
{
113-
code: [
114-
'function Foo() {',
115-
' return class Bar extends React.PureComponent {',
116-
' shouldComponentUpdate() {',
117-
' return true;',
118-
' }',
119-
' };',
120-
'}'
121-
].join('\n'),
114+
code: `
115+
function Foo() {
116+
return class Bar extends React.PureComponent {
117+
shouldComponentUpdate() {
118+
return true;
119+
}
120+
};
121+
}
122+
`,
122123
errors: [{message: errorMessage('Bar')}],
123124
parserOptions: parserOptions
124125
},
125126
{
126-
code: [
127-
'function Foo() {',
128-
' return class Bar extends PureComponent {',
129-
' shouldComponentUpdate() {',
130-
' return true;',
131-
' }',
132-
' };',
133-
'}'
134-
].join('\n'),
127+
code: `
128+
function Foo() {
129+
return class Bar extends PureComponent {
130+
shouldComponentUpdate() {
131+
return true;
132+
}
133+
};
134+
}
135+
`,
135136
errors: [{message: errorMessage('Bar')}],
136137
parserOptions: parserOptions
137138
},
138139
{
139-
code: [
140-
'var Foo = class extends PureComponent {',
141-
' shouldComponentUpdate() {',
142-
' return true;',
143-
' }',
144-
'}'
145-
].join('\n'),
140+
code: `
141+
var Foo = class extends PureComponent {
142+
shouldComponentUpdate() {
143+
return true;
144+
}
145+
}
146+
`,
146147
errors: [{message: errorMessage('Foo')}],
147148
parserOptions: parserOptions
148149
}

0 commit comments

Comments
 (0)