From 1c1c2497f969b274eb3106f25c4b206bbcb85932 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 28 Mar 2023 11:31:30 -0400 Subject: [PATCH] Based off meeting, ensure strict mode is tested --- .../helpers/ensure-safe-component-test.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/util/tests/integration/helpers/ensure-safe-component-test.js b/packages/util/tests/integration/helpers/ensure-safe-component-test.js index 29b51142e..85525bff1 100644 --- a/packages/util/tests/integration/helpers/ensure-safe-component-test.js +++ b/packages/util/tests/integration/helpers/ensure-safe-component-test.js @@ -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; @@ -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|}} + + {{/let}}`, + { + strict: true, + scope: () => ({ + ensureSafeComponent, + }), + } + ), + class extends Component { + thing = Thing; + } + ), + this + ); + await render(hbs` + + `); + assert.strictEqual(this.element.textContent.trim(), 'thing'); + }); + }); });