Skip to content

Commit 16b7d23

Browse files
NullVoxPopuliclaude
andcommitted
Address review: use state.htmlTag directly, restore arity tests
- Remove getTag helper wrapper; access state.htmlTag directly in scope - Restore "requires at least one argument" test - Restore "requires no more than one argument" test - Restore "does not take any named arguments" test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3716b8f commit 16b7d23

File tree

1 file changed

+46
-4
lines changed
  • packages/@ember/-internals/glimmer/tests/integration/helpers

1 file changed

+46
-4
lines changed

packages/@ember/-internals/glimmer/tests/integration/helpers/element-test.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DEBUG } from '@glimmer/env';
22
import { tracked } from '@glimmer/tracking';
3-
import { RenderingTestCase, defineSimpleHelper, moduleFor, runTask } from 'internal-test-helpers';
3+
import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers';
44
import { element as elementHelper, hash } from '@ember/helper';
55
import { on } from '@ember/modifier';
66
import { template } from '@ember/template-compiler/runtime';
@@ -82,11 +82,10 @@ moduleFor(
8282
}
8383

8484
let state = new State();
85-
let getTag = defineSimpleHelper(() => state.htmlTag);
8685

8786
let AComponent = template(
88-
`{{#let (element (getTag)) as |Tag|}}<Tag id="content">hello</Tag>{{/let}}`,
89-
{ scope: () => ({ element: elementHelper, getTag }) }
87+
`{{#let (element state.htmlTag) as |Tag|}}<Tag id="content">hello</Tag>{{/let}}`,
88+
{ scope: () => ({ element: elementHelper, state }) }
9089
);
9190
this.renderComponent(AComponent, {
9291
expect: '<h1 id="content">hello</h1>',
@@ -118,6 +117,49 @@ moduleFor(
118117
this.renderComponent(Outer, { expect: '<p id="content" class="extra">Test</p>' });
119118
}
120119

120+
['@test it requires at least one argument']() {
121+
if (!DEBUG) {
122+
this.assert.expect(0);
123+
return;
124+
}
125+
126+
this.assert.throws(() => {
127+
let AComponent = template(`{{#let (element) as |Tag|}}<Tag>hello</Tag>{{/let}}`, {
128+
scope: () => ({ element: elementHelper }),
129+
});
130+
this.renderComponent(AComponent, { expect: '' });
131+
}, /The `element` helper takes a single positional argument/);
132+
}
133+
134+
['@test it requires no more than one argument']() {
135+
if (!DEBUG) {
136+
this.assert.expect(0);
137+
return;
138+
}
139+
140+
this.assert.throws(() => {
141+
let AComponent = template(`{{#let (element "h1" "h2") as |Tag|}}<Tag>hello</Tag>{{/let}}`, {
142+
scope: () => ({ element: elementHelper }),
143+
});
144+
this.renderComponent(AComponent, { expect: '' });
145+
}, /The `element` helper takes a single positional argument/);
146+
}
147+
148+
['@test it does not take any named arguments']() {
149+
if (!DEBUG) {
150+
this.assert.expect(0);
151+
return;
152+
}
153+
154+
this.assert.throws(() => {
155+
let AComponent = template(
156+
`{{#let (element "h1" id="content") as |Tag|}}<Tag>hello</Tag>{{/let}}`,
157+
{ scope: () => ({ element: elementHelper }) }
158+
);
159+
this.renderComponent(AComponent, { expect: '' });
160+
}, /The `element` helper does not take any named arguments/);
161+
}
162+
121163
['@test it throws when passed a number']() {
122164
if (!DEBUG) {
123165
this.assert.expect(0);

0 commit comments

Comments
 (0)