|
1 | 1 | import { DEBUG } from '@glimmer/env'; |
2 | 2 | import { tracked } from '@glimmer/tracking'; |
3 | | -import { RenderingTestCase, defineSimpleHelper, moduleFor, runTask } from 'internal-test-helpers'; |
| 3 | +import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers'; |
4 | 4 | import { element as elementHelper, hash } from '@ember/helper'; |
5 | 5 | import { on } from '@ember/modifier'; |
6 | 6 | import { template } from '@ember/template-compiler/runtime'; |
@@ -82,11 +82,10 @@ moduleFor( |
82 | 82 | } |
83 | 83 |
|
84 | 84 | let state = new State(); |
85 | | - let getTag = defineSimpleHelper(() => state.htmlTag); |
86 | 85 |
|
87 | 86 | 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 }) } |
90 | 89 | ); |
91 | 90 | this.renderComponent(AComponent, { |
92 | 91 | expect: '<h1 id="content">hello</h1>', |
@@ -118,6 +117,49 @@ moduleFor( |
118 | 117 | this.renderComponent(Outer, { expect: '<p id="content" class="extra">Test</p>' }); |
119 | 118 | } |
120 | 119 |
|
| 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 | + |
121 | 163 | ['@test it throws when passed a number']() { |
122 | 164 | if (!DEBUG) { |
123 | 165 | this.assert.expect(0); |
|
0 commit comments