Skip to content

Commit 906a951

Browse files
committed
test: add 'transforms for require() with template literal'
1 parent eb07c7c commit 906a951

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/plugin.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
},
@@ -51,6 +51,18 @@ describe('Babel Root Import - Plugin', () => {
5151
expect(transformed.code).to.contain(targetRequire);
5252
});
5353

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+
5466
it('transforms for custom functions', () => {
5567
const targetRequire = slash(`/some/example.js`);
5668
const transformed = babelTransform(

0 commit comments

Comments
 (0)