@@ -19,7 +19,9 @@ describe('extendsHandler', () => {
1919 resolveRequiredMock = resolveRequired as jest . Mock <
2020 ( ast : bt . File , varNameFilter ?: string [ ] ) => { [ key : string ] : string }
2121 >
22- resolveRequiredMock . mockReturnValue ( { testComponent : './componentPath' } )
22+ resolveRequiredMock . mockReturnValue ( {
23+ testComponent : { filePath : './componentPath' , exportName : 'default' } ,
24+ } )
2325
2426 mockResolvePathFrom = resolvePathFrom as jest . Mock < ( path : string , from : string ) => string >
2527 mockResolvePathFrom . mockReturnValue ( './component/full/path' )
@@ -30,8 +32,10 @@ describe('extendsHandler', () => {
3032
3133 function parseItExtends ( src : string ) {
3234 const ast = babylon ( ) . parse ( src )
33- const path = resolveExportedComponent ( ast )
34- extendsHandler ( doc , path [ 0 ] , ast , '' )
35+ const path = resolveExportedComponent ( ast ) . get ( 'default' )
36+ if ( path ) {
37+ extendsHandler ( doc , path , ast , '' )
38+ }
3539 }
3640
3741 it ( 'should resolve extended modules variables in import default' , ( ) => {
@@ -42,7 +46,7 @@ describe('extendsHandler', () => {
4246 '}' ,
4347 ] . join ( '\n' )
4448 parseItExtends ( src )
45- expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc )
49+ expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc , [ 'default' ] )
4650 } )
4751
4852 it ( 'should resolve extended modules variables in require' , ( ) => {
@@ -53,27 +57,28 @@ describe('extendsHandler', () => {
5357 '}' ,
5458 ] . join ( '\n' )
5559 parseItExtends ( src )
56- expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc )
60+ expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc , [ 'default' ] )
5761 } )
5862
5963 it ( 'should resolve extended modules variables in import' , ( ) => {
6064 const src = [
61- 'import { testComponent, other } from "./testComponent"' ,
65+ 'import { test as testComponent, other } from "./testComponent"' ,
6266 'export default {' ,
6367 ' extends:testComponent' ,
6468 '}' ,
6569 ] . join ( '\n' )
6670 parseItExtends ( src )
67- expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc )
71+ expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc , [ 'default' ] )
6872 } )
6973
7074 it ( 'should resolve extended modules variables in class style components' , ( ) => {
7175 const src = [
72- 'import { testComponent} from "./testComponent"' ,
76+ 'import { testComponent } from "./testComponent";' ,
77+ '@Component' ,
7378 'export default class Bart extends testComponent {' ,
7479 '}' ,
7580 ] . join ( '\n' )
7681 parseItExtends ( src )
77- expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc )
82+ expect ( parseFile ) . toHaveBeenCalledWith ( './component/full/path' , doc , [ 'default' ] )
7883 } )
7984} )
0 commit comments