Skip to content

Commit

Permalink
Try to reproduce emberjs/ember.js#19877
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Dec 18, 2021
1 parent 83d8bac commit 49f6972
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Empty file removed tests/dummy/app/helpers/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions tests/dummy/app/helpers/service.js
Original file line number Diff line number Diff line change
@@ -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}`);
}
}
16 changes: 16 additions & 0 deletions tests/integration/gjs-test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
});
});

0 comments on commit 49f6972

Please sign in to comment.