From af323bb394b06f1751b8eabf7f26e1a2e514ec22 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sun, 24 Oct 2021 18:18:46 -0400 Subject: [PATCH] Add test confirming lexical scope works with `await render` This requires Ember 3.28.4+ --- .../setup-rendering-context-test.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/setup-rendering-context-test.js b/tests/integration/setup-rendering-context-test.js index cb67c5b92..044b14177 100644 --- a/tests/integration/setup-rendering-context-test.js +++ b/tests/integration/setup-rendering-context-test.js @@ -1,6 +1,7 @@ import Ember from 'ember'; import { module, test } from 'qunit'; import Component from '@ember/component'; +import { helper } from '@ember/component/helper'; import { setupContext, setupRenderingContext, @@ -13,6 +14,7 @@ import { import hasEmberVersion from '@ember/test-helpers/has-ember-version'; import { setResolverRegistry } from '../helpers/resolver'; import { hbs } from 'ember-cli-htmlbars'; +import { precompileTemplate } from '@ember/template-compilation'; import { defer } from 'rsvp'; const PromiseWrapperTemplate = hbs` @@ -144,4 +146,24 @@ module('setupRenderingContext "real world"', function (hooks) { 'the rootElement has the correct content after clicking' ); }); + + module('lexical scope access', function () { + if (hasEmberVersion(3, 28)) { + test('can render components passed as locals', async function (assert) { + let add = helper(function ([first, second]) { + return first + second; + }); + + await render( + precompileTemplate('{{add 1 3}}', { + scope() { + return { add }; + }, + }) + ); + + assert.equal(this.element.textContent, '4'); + }); + } + }); });