From 49f697218198a05aea0b128a4b2f4aab8178c872 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Fri, 17 Dec 2021 22:53:38 -0500 Subject: [PATCH] Try to reproduce https://github.com/emberjs/ember.js/issues/19877 --- tests/dummy/app/helpers/.gitkeep | 0 tests/dummy/app/helpers/service.js | 8 ++++++++ tests/integration/gjs-test.gjs | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) delete mode 100644 tests/dummy/app/helpers/.gitkeep create mode 100644 tests/dummy/app/helpers/service.js diff --git a/tests/dummy/app/helpers/.gitkeep b/tests/dummy/app/helpers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/helpers/service.js b/tests/dummy/app/helpers/service.js new file mode 100644 index 0000000..921088e --- /dev/null +++ b/tests/dummy/app/helpers/service.js @@ -0,0 +1,8 @@ +import { getOwner } from '@ember/application'; +import Helper from '@ember/component/helper'; + +export default class GetService extends Helper { + compute([name]) { + return getOwner(this).lookup(`service:${name}`); + } +} diff --git a/tests/integration/gjs-test.gjs b/tests/integration/gjs-test.gjs index fcb9a88..96e1552 100644 --- a/tests/integration/gjs-test.gjs +++ b/tests/integration/gjs-test.gjs @@ -4,6 +4,7 @@ import { render } from '@ember/test-helpers'; import { precompileTemplate } from '@ember/template-compilation'; import Component from '@glimmer/component'; +import GetService from 'dummy/helpers/get-service'; import GjsTest from 'dummy/components/gjs-test'; module('tests/integration/components/gjs', function (hooks) { @@ -49,4 +50,19 @@ module('tests/integration/components/gjs', function (hooks) { assert.equal(this.element.textContent.trim(), 'Hello, world!'); }); + + test('it works with ember helpers', async function (assert) { + await render( + precompileTemplate(` + {{#let (service 'router') as |router|}} + {{router.currentRouteName}} hi + {{/let}} + `, { + strictMode: true, + scope: () => ({ service: GetService }), + }) + ); + + assert.equal(this.element.textContent.trim(), 'index hi'); + }); });