File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
- import { parse , noopImporter } from '../../../tests/utils' ;
9
+ import {
10
+ parse ,
11
+ statement ,
12
+ noopImporter ,
13
+ makeMockImporter ,
14
+ } from '../../../tests/utils' ;
10
15
import resolveToModule from '../resolveToModule' ;
11
16
12
17
describe ( 'resolveToModule' , ( ) => {
@@ -15,6 +20,18 @@ describe('resolveToModule', () => {
15
20
return root . get ( 'body' , root . node . body . length - 1 , 'expression' ) ;
16
21
}
17
22
23
+ const mockImporter = makeMockImporter ( {
24
+ Foo : statement ( `
25
+ export default bar;
26
+ import bar from 'Bar';
27
+ ` ) . get ( 'declaration' ) ,
28
+
29
+ Bar : statement ( `
30
+ export default baz;
31
+ import baz from 'Baz';
32
+ ` ) . get ( 'declaration' ) ,
33
+ } ) ;
34
+
18
35
it ( 'resolves identifiers' , ( ) => {
19
36
const path = parsePath ( `
20
37
var foo = require("Foo");
@@ -85,5 +102,13 @@ describe('resolveToModule', () => {
85
102
` ) ;
86
103
expect ( resolveToModule ( path , noopImporter ) ) . toBe ( 'Foo' ) ;
87
104
} ) ;
105
+
106
+ it ( 'can resolve imports until one not expanded' , ( ) => {
107
+ const path = parsePath ( `
108
+ import foo from "Foo";
109
+ foo;
110
+ ` ) ;
111
+ expect ( resolveToModule ( path , mockImporter ) ) . toBe ( 'Baz' ) ;
112
+ } ) ;
88
113
} ) ;
89
114
} ) ;
You can’t perform that action at this time.
0 commit comments