Skip to content

Commit 11481d5

Browse files
committed
Prototype failing test
1 parent d72607e commit 11481d5

File tree

2 files changed

+5387
-4321
lines changed

2 files changed

+5387
-4321
lines changed

__tests__/tests.ts

+28
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,34 @@ describe('htmlbars-inline-precompile', function () {
19011901
`);
19021902
});
19031903

1904+
it('uses allowed platform globals when used', function () {
1905+
plugins = [
1906+
[
1907+
HTMLBarsInlinePrecompile,
1908+
{
1909+
compiler,
1910+
targetFormat: 'hbs',
1911+
},
1912+
],
1913+
];
1914+
1915+
let transformed = transform(
1916+
`import { template } from '@ember/template-compiler';
1917+
const data = {};
1918+
export default template('{{JSON.stringify data}}', { eval: function() { return eval(arguments[0]) } })
1919+
`
1920+
);
1921+
1922+
expect(transformed).toEqualCode(`
1923+
import HelloWorld from "somewhere";
1924+
import { precompileTemplate } from "@ember/template-compilation";
1925+
import { setComponentTemplate } from "@ember/component";
1926+
import templateOnly from "@ember/component/template-only";
1927+
const data = {};
1928+
export default setComponentTemplate(precompileTemplate('{{JSON.stringify data}}', { strictMode: true, scope: () => ({ JSON, data }) }), templateOnly());
1929+
`);
1930+
});
1931+
19041932
// You might think this would be confusing style, and you'd be correct. But
19051933
// that's what the lint rules are for. When it comes to correctness, we need
19061934
// our scope to behave like real Javascript, and Javascript doesn't care

0 commit comments

Comments
 (0)