Skip to content

Commit

Permalink
add staticModifiers tests for bare mustache invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
void-mAlex committed Jan 26, 2023
1 parent f455646 commit 31e7e25
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/compat/tests/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,62 @@ describe('compat-resolver', function () {
});
`);
});
test('modifier in bare mustache, no args', function () {
let transform = configure({
staticModifiers: false,
});
givenFile('modifiers/scroll-top.js');
expect(transform('templates/application.hbs', `<div {{scroll-top}}>Test</div>`)).toEqualCode(`
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate("<div {{scroll-top}}>Test</div>", {
moduleName: "my-app/templates/application.hbs",
});
`);
});
test('modifier in bare mustache, with args', function () {
let transform = configure({
staticModifiers: false,
});
givenFile('modifiers/scroll-top.js');
expect(transform('templates/application.hbs', `<div {{scroll-top @scrollTopPosition}}>Test</div>`)).toEqualCode(`
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate("<div {{scroll-top @scrollTopPosition}}>Test</div>", {
moduleName: "my-app/templates/application.hbs",
});
`);
});
test('modifier in bare mustache, no args', function () {
let transform = configure({
staticModifiers: true,
});
givenFile('modifiers/scroll-top.js');
expect(transform('templates/application.hbs', `<div {{scroll-top}}>Test</div>`)).toEqualCode(`
import scrollTop from "../modifiers/scroll-top.js";
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate("<div {{scrollTop}}>Test</div>", {
moduleName: "my-app/templates/application.hbs",
scope: () => ({
scrollTop
})
});
`);
});
test('modifier in bare mustache, with args', function () {
let transform = configure({
staticModifiers: true,
});
givenFile('modifiers/scroll-top.js');
expect(transform('templates/application.hbs', `<div {{scroll-top @scrollTopPosition}}>Test</div>`)).toEqualCode(`
import scrollTop from "../modifiers/scroll-top.js";
import { precompileTemplate } from "@ember/template-compilation";
export default precompileTemplate("<div {{scrollTop @scrollTopPosition}}>Test</div>", {
moduleName: "my-app/templates/application.hbs",
scope: () => ({
scrollTop
})
});
`);
});
test('modifier currying using the "modifier" keyword', function () {
let transform = configure({ staticModifiers: true });
givenFile('modifiers/add-listener.js');
Expand Down

0 comments on commit 31e7e25

Please sign in to comment.