File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
- import { parse , statement , noopImporter } from '../../../tests/utils' ;
9
+ import {
10
+ parse ,
11
+ statement ,
12
+ noopImporter ,
13
+ makeMockImporter ,
14
+ } from '../../../tests/utils' ;
10
15
import isStatelessComponent from '../isStatelessComponent' ;
11
16
12
17
describe ( 'isStatelessComponent' , ( ) => {
@@ -213,14 +218,20 @@ describe('isStatelessComponent', () => {
213
218
} ) ;
214
219
215
220
describe ( 'resolving return values' , ( ) => {
216
- function test ( desc , code ) {
221
+ function test ( desc , code , importer = noopImporter ) {
217
222
it ( desc , ( ) => {
218
223
const def = parse ( code ) . get ( 'body' , 1 ) ;
219
224
220
- expect ( isStatelessComponent ( def , noopImporter ) ) . toBe ( true ) ;
225
+ expect ( isStatelessComponent ( def , importer ) ) . toBe ( true ) ;
221
226
} ) ;
222
227
}
223
228
229
+ const mockImporter = makeMockImporter ( {
230
+ bar : statement ( `
231
+ export default <div />;
232
+ ` ) . get ( 'declaration' ) ,
233
+ } ) ;
234
+
224
235
it ( 'does not see ifs as separate block' , ( ) => {
225
236
const def = statement ( `
226
237
function Foo (props) {
@@ -338,5 +349,16 @@ describe('isStatelessComponent', () => {
338
349
}
339
350
` ,
340
351
) ;
352
+
353
+ test (
354
+ 'resolves imported values as return' ,
355
+ `
356
+ import bar from 'bar';
357
+ function Foo (props) {
358
+ return bar;
359
+ }
360
+ ` ,
361
+ mockImporter ,
362
+ ) ;
341
363
} ) ;
342
364
} ) ;
You can’t perform that action at this time.
0 commit comments