Skip to content

Commit

Permalink
Merge pull request #1 from jamescdavis/leave-blocks-alone
Browse files Browse the repository at this point in the history
add test for angle-bracket-like name invoked with curlies
  • Loading branch information
dfreeman authored Jan 28, 2021
2 parents a3bf701 + e78a219 commit fe3bf18
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ module('[glimmer-compiler] precompile', ({ test }) => {
assert.equal(componentName, 'my-component', 'original component name was used');
});

test('customizeComponentName is not invoked on angle-bracket-like name invoked with curlies', function (assert) {
let wire = JSON.parse(
precompile('{{#MyComponent}}hello{{/MyComponent}}', {
customizeComponentName(input: string) {
return input.toUpperCase();
},
})
);

let block: WireFormat.SerializedTemplateBlock = JSON.parse(wire.block);

let [[, componentNameExpr]] = block[0] as [WireFormat.Statements.Block];

glimmerAssert(
Array.isArray(componentNameExpr) &&
componentNameExpr[0] === SexpOpcodes.GetFreeAsComponentHead,
`component name is a free variable lookup`
);

let componentName = block[3][componentNameExpr[1]];
assert.equal(componentName, 'MyComponent', 'original component name was used');
});

test('lowercased names are not resolved or customized in resolution mode', (assert) => {
let wire = JSON.parse(
precompile('<rental />', {
Expand Down

0 comments on commit fe3bf18

Please sign in to comment.