1
1
import {
2
- registerHandlebarsCompatibleHelper
2
+ registerHandlebarsCompatibleHelper as registerHelper
3
3
} from 'ember-htmlbars/compat/helper' ;
4
4
5
5
import EmberView from 'ember-views/views/view' ;
@@ -18,6 +18,12 @@ import viewKeyword from 'ember-htmlbars/keywords/view';
18
18
19
19
var view , registry , container , originalViewKeyword ;
20
20
21
+ function registerHandlebarsCompatibleHelper ( ) {
22
+ expectDeprecation ( 'Ember.Handlebars.registerHelper is deprecated, please refactor to Ember.Helper.helper.' ) ;
23
+
24
+ return registerHelper ( ...arguments ) ;
25
+ }
26
+
21
27
QUnit . module ( 'ember-htmlbars: compat - Handlebars compatible helpers' , {
22
28
setup ( ) {
23
29
originalViewKeyword = registerKeyword ( 'view' , viewKeyword ) ;
@@ -40,7 +46,7 @@ QUnit.module('ember-htmlbars: compat - Handlebars compatible helpers', {
40
46
} ) ;
41
47
42
48
QUnit . test ( 'wraps provided function so that original path params are provided to the helper' , function ( ) {
43
- expect ( 2 ) ;
49
+ expect ( 3 ) ;
44
50
45
51
function someHelper ( param1 , param2 , options ) {
46
52
equal ( param1 , 'blammo' ) ;
@@ -60,7 +66,7 @@ QUnit.test('wraps provided function so that original path params are provided to
60
66
} ) ;
61
67
62
68
QUnit . test ( 'combines `env` and `options` for the wrapped helper' , function ( ) {
63
- expect ( 1 ) ;
69
+ expect ( 2 ) ;
64
70
65
71
function someHelper ( options ) {
66
72
equal ( options . data . view , view ) ;
@@ -79,7 +85,7 @@ QUnit.test('combines `env` and `options` for the wrapped helper', function() {
79
85
} ) ;
80
86
81
87
QUnit . test ( 'combines `env` and `options` for the wrapped helper' , function ( ) {
82
- expect ( 1 ) ;
88
+ expect ( 2 ) ;
83
89
84
90
function someHelper ( options ) {
85
91
equal ( options . data . view , view ) ;
@@ -122,7 +128,7 @@ QUnit.test('has the correct options.data.view within a components layout', funct
122
128
} ) ;
123
129
124
130
QUnit . test ( 'adds `hash` into options `options` for the wrapped helper' , function ( ) {
125
- expect ( 1 ) ;
131
+ expect ( 2 ) ;
126
132
127
133
function someHelper ( options ) {
128
134
equal ( options . hash . bestFriend , 'Jacquie' ) ;
@@ -141,7 +147,7 @@ QUnit.test('adds `hash` into options `options` for the wrapped helper', function
141
147
} ) ;
142
148
143
149
QUnit . test ( 'bound `hash` params are provided with their original paths' , function ( ) {
144
- expect ( 1 ) ;
150
+ expect ( 2 ) ;
145
151
146
152
function someHelper ( options ) {
147
153
equal ( options . hash . bestFriend , 'value' ) ;
@@ -160,7 +166,7 @@ QUnit.test('bound `hash` params are provided with their original paths', functio
160
166
} ) ;
161
167
162
168
QUnit . test ( 'bound ordered params are provided with their original paths' , function ( ) {
163
- expect ( 2 ) ;
169
+ expect ( 3 ) ;
164
170
165
171
function someHelper ( param1 , param2 , options ) {
166
172
equal ( param1 , 'first' ) ;
@@ -181,13 +187,17 @@ QUnit.test('bound ordered params are provided with their original paths', functi
181
187
} ) ;
182
188
183
189
QUnit . test ( 'registering a helper created from `Ember.Handlebars.makeViewHelper` does not double wrap the helper' , function ( ) {
184
- expect ( 1 ) ;
190
+ expect ( 3 ) ;
185
191
186
192
var ViewHelperComponent = Component . extend ( {
187
193
layout : compile ( 'woot!' )
188
194
} ) ;
189
195
190
- var helper = makeViewHelper ( ViewHelperComponent ) ;
196
+ var helper ;
197
+ expectDeprecation ( function ( ) {
198
+ helper = makeViewHelper ( ViewHelperComponent ) ;
199
+ } , '`Ember.Handlebars.makeViewHelper` and `Ember.HTMLBars.makeViewHelper` are deprecated. Please refactor to normal component usage.' ) ;
200
+
191
201
registerHandlebarsCompatibleHelper ( 'view-helper' , helper ) ;
192
202
193
203
view = EmberView . extend ( {
@@ -200,15 +210,18 @@ QUnit.test('registering a helper created from `Ember.Handlebars.makeViewHelper`
200
210
} ) ;
201
211
202
212
QUnit . test ( 'makes helpful assertion when called with invalid arguments' , function ( ) {
203
- expect ( 1 ) ;
213
+ expect ( 3 ) ;
204
214
205
215
var ViewHelperComponent = Component . extend ( {
206
216
layout : compile ( 'woot!' )
207
217
} ) ;
208
218
209
219
ViewHelperComponent . toString = function ( ) { return 'Some Random Class' ; } ;
210
220
211
- var helper = makeViewHelper ( ViewHelperComponent ) ;
221
+ var helper ;
222
+ expectDeprecation ( function ( ) {
223
+ helper = makeViewHelper ( ViewHelperComponent ) ;
224
+ } , '`Ember.Handlebars.makeViewHelper` and `Ember.HTMLBars.makeViewHelper` are deprecated. Please refactor to normal component usage.' ) ;
212
225
registerHandlebarsCompatibleHelper ( 'view-helper' , helper ) ;
213
226
214
227
view = EmberView . extend ( {
@@ -221,7 +234,7 @@ QUnit.test('makes helpful assertion when called with invalid arguments', functio
221
234
} ) ;
222
235
223
236
QUnit . test ( 'does not add `options.fn` if no block was specified' , function ( ) {
224
- expect ( 1 ) ;
237
+ expect ( 2 ) ;
225
238
226
239
function someHelper ( options ) {
227
240
ok ( ! options . fn , '`options.fn` is not present when block is not specified' ) ;
@@ -240,7 +253,7 @@ QUnit.test('does not add `options.fn` if no block was specified', function() {
240
253
} ) ;
241
254
242
255
QUnit . test ( 'does not return helper result if block was specified' , function ( ) {
243
- expect ( 1 ) ;
256
+ expect ( 2 ) ;
244
257
245
258
function someHelper ( options ) {
246
259
return 'asdf' ;
@@ -261,7 +274,7 @@ QUnit.test('does not return helper result if block was specified', function() {
261
274
} ) ;
262
275
263
276
QUnit . test ( 'allows usage of the template fn' , function ( ) {
264
- expect ( 1 ) ;
277
+ expect ( 2 ) ;
265
278
266
279
function someHelper ( options ) {
267
280
options . fn ( ) ;
@@ -282,7 +295,7 @@ QUnit.test('allows usage of the template fn', function() {
282
295
} ) ;
283
296
284
297
QUnit . test ( 'allows usage of the template inverse' , function ( ) {
285
- expect ( 1 ) ;
298
+ expect ( 2 ) ;
286
299
287
300
function someHelper ( options ) {
288
301
options . inverse ( ) ;
@@ -303,7 +316,7 @@ QUnit.test('allows usage of the template inverse', function() {
303
316
} ) ;
304
317
305
318
QUnit . test ( 'ordered param types are added to options.types' , function ( ) {
306
- expect ( 3 ) ;
319
+ expect ( 4 ) ;
307
320
308
321
function someHelper ( param1 , param2 , param3 , options ) {
309
322
equal ( options . types [ 0 ] , 'NUMBER' ) ;
@@ -325,7 +338,7 @@ QUnit.test('ordered param types are added to options.types', function() {
325
338
} ) ;
326
339
327
340
QUnit . test ( '`hash` params are to options.hashTypes' , function ( ) {
328
- expect ( 3 ) ;
341
+ expect ( 4 ) ;
329
342
330
343
function someHelper ( options ) {
331
344
equal ( options . hashTypes . string , 'STRING' ) ;
0 commit comments