@@ -15,7 +15,9 @@ import { Preprocessor } from 'content-tag';
15
15
16
16
describe ( 'htmlbars-inline-precompile' , function ( ) {
17
17
// eslint-disable-next-line @typescript-eslint/no-var-requires
18
- let compiler : EmberTemplateCompiler = { ...require ( 'ember-source/dist/ember-template-compiler' ) } ;
18
+ let compiler : EmberTemplateCompiler = {
19
+ ...require ( 'ember-source/dist/ember-template-compiler.js' ) ,
20
+ } ;
19
21
let plugins : ( [ typeof HTMLBarsInlinePrecompile , Options ] | [ unknown ] ) [ ] ;
20
22
21
23
function transform ( code : string ) {
@@ -1874,13 +1876,30 @@ describe('htmlbars-inline-precompile', function () {
1874
1876
1875
1877
it ( 'can pass lexically scoped "this"' , function ( ) {
1876
1878
let spy = sinon . spy ( compiler , 'precompile' ) ;
1877
- transform ( `
1879
+ let transformed = transform ( `
1878
1880
import { precompileTemplate } from '@ember/template-compilation';
1879
1881
export function example() {
1880
1882
return precompileTemplate('{{this.message}}', { scope: () => ({ "this": this }) });
1881
1883
}
1882
1884
` ) ;
1883
1885
expect ( spy . firstCall . lastArg ) . toHaveProperty ( 'locals' , [ 'this' ] ) ;
1886
+ expect ( normalizeWireFormat ( transformed ) ) . toEqualCode ( `
1887
+ import { createTemplateFactory } from "@ember/template-factory";
1888
+ export function example() {
1889
+ return createTemplateFactory(
1890
+ /*
1891
+ {{this.message}}
1892
+ */
1893
+ {
1894
+ id: "<id>",
1895
+ block: '[[[1,[32,0,["message"]]]],[],false,[]]',
1896
+ moduleName: "<moduleName>",
1897
+ scope: () => [this],
1898
+ isStrictMode: false,
1899
+ }
1900
+ );
1901
+ }
1902
+ ` ) ;
1884
1903
} ) ;
1885
1904
} ) ;
1886
1905
@@ -2196,7 +2215,7 @@ describe('htmlbars-inline-precompile', function () {
2196
2215
2197
2216
let transformed = transform (
2198
2217
p . process (
2199
- `import HelloWorld from 'somewhere';
2218
+ `
2200
2219
export function example() {
2201
2220
return <template>{{this.message}}</template>;
2202
2221
}
@@ -2209,7 +2228,7 @@ describe('htmlbars-inline-precompile', function () {
2209
2228
import { setComponentTemplate } from "@ember/component";
2210
2229
import templateOnly from "@ember/component/template-only";
2211
2230
export function example() {
2212
- return setComponentTemplate(precompileTemplate('{{this.message}}', { strictMode: true, scope: () => ({ " this" : this }) }), templateOnly());
2231
+ return setComponentTemplate(precompileTemplate('{{this.message}}', { strictMode: true, scope: () => ({ this: this }) }), templateOnly());
2213
2232
}
2214
2233
` ) ;
2215
2234
} ) ;
0 commit comments