Skip to content

Commit

Permalink
Based off meeting, ensure strict mode is tested
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Mar 28, 2023
1 parent e7c1789 commit 1c1c249
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ensureSafeComponent } from '@embroider/util';
import * as SomeComponentModule from 'dummy/components/some-component';
import ColocatedExample from 'dummy/components/colocated-example';
import { setOwner } from '@ember/application';
import { precompileTemplate } from '@ember/template-compilation';

const SomeComponent = SomeComponentModule.default;

Expand Down Expand Up @@ -175,4 +176,34 @@ module('Integration | Helper | ensure-safe-component', function (hooks) {
assert.strictEqual(this.element.textContent.trim(), 'second:goodbye');
assert.deepEqual(log, ['target instantiated', 'new target instantiated']);
});

module('with strict: true', function () {
test('reference to class property-as-component is allowed', async function (assert) {
const Thing = setComponentTemplate(hbs`thing`, templateOnlyComponent());

this.inner = ensureSafeComponent(
setComponentTemplate(
precompileTemplate(
`{{#let (component (ensureSafeComponent this.thing)) as |Thing|}}
<Thing />
{{/let}}`,
{
strict: true,
scope: () => ({
ensureSafeComponent,
}),
}
),
class extends Component {
thing = Thing;
}
),
this
);
await render(hbs`
<this.inner @name={{component "some-component"}} />
`);
assert.strictEqual(this.element.textContent.trim(), 'thing');
});
});
});

0 comments on commit 1c1c249

Please sign in to comment.