diff --git a/__tests__/tests.ts b/__tests__/tests.ts index 15e10c5..15a440a 100644 --- a/__tests__/tests.ts +++ b/__tests__/tests.ts @@ -2457,6 +2457,41 @@ describe('htmlbars-inline-precompile', function () { `); }); + it('expression form can capture underscore vars', async function () { + plugins = [ + [ + HTMLBarsInlinePrecompile, + { + compiler, + targetFormat: 'hbs', + }, + ], + ]; + + let p = new Preprocessor(); + + let transformed = await transform( + p.process( + ` + const _Foo = ; + export function example() { + return ; + } + ` + ) + ); + + expect(transformed).toEqualCode(` + import { precompileTemplate } from "@ember/template-compilation"; + import { setComponentTemplate } from "@ember/component"; + import templateOnly from "@ember/component/template-only"; + const _Foo = setComponentTemplate(precompileTemplate("", { strictMode: true }), templateOnly()); + export function example() { + return setComponentTemplate(precompileTemplate('<_Foo />', { strictMode: true, scope: () => ({ _Foo }) }), templateOnly()); + } + `); + }); + it('expression form can capture lexical "this"', async function () { plugins = [ [