Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for helper name collisions with html elements or js keywords #1381

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/scenarios/compat-resolver-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,42 @@ Scenarios.fromProject(() => new Project())
`);
});

test('helper name collision with html element', async function () {
givenFiles({
'templates/application.hbs': `{{#let (div this.a this.b) as |c|}}
<div>{{c}}</div>
{{/let}}`,
});
await configure({ staticHelpers: true });
expectTranspiled('templates/application.hbs').equalsCode(`
import div_ from "#embroider_compat/helpers/div";
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate('{{#let (div_ this.a this.b) as |c|}}\\n <div>{{c}}</div>\\n {{/let}}', {
moduleName: "my-app/templates/application.hbs",
scope: () => ({
div_
})
});
`);
});

test('helper name collision with js reserved keyword', async function () {
givenFiles({
'templates/application.hbs': `<div class={{await 1}}/>`,
});
await configure({ staticHelpers: true });
expectTranspiled('templates/application.hbs').equalsCode(`
import await_ from "#embroider_compat/helpers/await";
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate("<div class={{await_ 1}} />", {
moduleName: "my-app/templates/application.hbs",
scope: () => ({
await_,
}),
});
`);
});

test('helper in content position, manually disambiguated', async function () {
givenFiles({
'templates/application.hbs': `{{myHelper}}`,
Expand Down