@@ -31,9 +31,9 @@ describe('Babel Root Import - Plugin', () => {
3131 } ) ;
3232
3333 it ( 'transforms for import() syntax' , ( ) => {
34- const targetRequire = slash ( `/some/example.js` ) ;
34+ const targetRequire = slash ( `". /some/example.js" ` ) ;
3535 const transformed = babelTransform (
36- " var SomeExample = import(' ~/some/example.js');" ,
36+ ' var SomeExample = import(" ~/some/example.js");' ,
3737 {
3838 plugins : [ importSyntaxPlugin , BabelRootImportPlugin ] ,
3939 } ,
@@ -42,6 +42,27 @@ describe('Babel Root Import - Plugin', () => {
4242 expect ( transformed . code ) . to . contain ( targetRequire ) ;
4343 } ) ;
4444
45+ it ( 'transforms for import() syntax with template literal' , ( ) => {
46+ const targetRequire = slash ( '`./some/${foo}`' ) ;
47+ const transformed = babelTransform ( 'var SomeExample = import(`~/some/${foo}`);' , {
48+ plugins : [ importSyntaxPlugin , BabelRootImportPlugin ] ,
49+ } ) ;
50+
51+ expect ( transformed . code ) . to . contain ( targetRequire ) ;
52+ } ) ;
53+
54+ it ( 'transforms for require() with template literal' , ( ) => {
55+ const targetRequire = slash ( '`./some/${foo}`' ) ;
56+ const transformed = babelTransform (
57+ 'var SomeExample = require(`~/some/${foo}`);' ,
58+ {
59+ plugins : [ BabelRootImportPlugin ] ,
60+ } ,
61+ ) ;
62+
63+ expect ( transformed . code ) . to . contain ( targetRequire ) ;
64+ } ) ;
65+
4566 it ( 'transforms for custom functions' , ( ) => {
4667 const targetRequire = slash ( `/some/example.js` ) ;
4768 const transformed = babelTransform (
0 commit comments