@@ -80,13 +80,22 @@ module('setupRenderingContext', function (hooks) {
80
80
hooks . beforeEach ( async function ( ) {
81
81
setResolverRegistry ( {
82
82
'service:foo' : Service . extend ( { isFoo : true } ) ,
83
- 'template:components/template-only' : hbs `template-only component here` ,
83
+ 'component:template-only' : setComponentTemplate (
84
+ hbs `template-only component here` ,
85
+ class extends Component { }
86
+ ) ,
84
87
'component:js-only' : Component . extend ( {
85
88
classNames : [ 'js-only' ] ,
86
89
} ) ,
87
90
'helper:jax' : helper ( ( [ name ] ) => `${ name } -jax` ) ,
88
- 'template:components/outer-comp' : hbs `outer{{inner-comp}}outer` ,
89
- 'template:components/inner-comp' : hbs `inner` ,
91
+ 'component:outer-comp' : setComponentTemplate (
92
+ hbs `outer{{inner-comp}}outer` ,
93
+ class extends Component { }
94
+ ) ,
95
+ 'component:inner-comp' : setComponentTemplate (
96
+ hbs `inner` ,
97
+ class extends Component { }
98
+ ) ,
90
99
} ) ;
91
100
92
101
await setupContext ( this ) ;
@@ -113,10 +122,16 @@ module('setupRenderingContext', function (hooks) {
113
122
}
114
123
115
124
let alternateOwner = await buildEngineOwner ( this . owner , {
116
- 'template:components/foo' : hbs `hello!` ,
125
+ 'component:foo' : setComponentTemplate (
126
+ hbs `hello!` ,
127
+ class extends Component { }
128
+ ) ,
117
129
} ) ;
118
130
119
- this . owner . register ( 'template:components/foo' , hbs `noooooooo!` ) ;
131
+ this . owner . register (
132
+ 'component:foo' ,
133
+ setComponentTemplate ( hbs `noooooooo!` , class extends Component { } )
134
+ ) ;
120
135
121
136
await render ( hbs `<Foo />` , { owner : alternateOwner } ) ;
122
137
@@ -292,7 +307,10 @@ module('setupRenderingContext', function (hooks) {
292
307
} ) ;
293
308
294
309
test ( 'can use the component helper in its layout' , async function ( assert ) {
295
- this . owner . register ( 'template:components/x-foo' , hbs `x-foo here` ) ;
310
+ this . owner . register (
311
+ 'component:x-foo' ,
312
+ setComponentTemplate ( hbs `x-foo here` , class extends Component { } )
313
+ ) ;
296
314
297
315
await render ( hbs `{{component 'x-foo'}}` ) ;
298
316
@@ -319,15 +337,14 @@ module('setupRenderingContext', function (hooks) {
319
337
320
338
this . owner . register (
321
339
'component:x-foo' ,
322
- Component . extend ( {
323
- click ( ) {
324
- assert . ok ( true , 'click was fired' ) ;
325
- } ,
326
- } )
327
- ) ;
328
- this . owner . register (
329
- 'template:components/x-foo' ,
330
- hbs `<button>Click me!</button>`
340
+ setComponentTemplate (
341
+ hbs `<button>Click me!</button>` ,
342
+ Component . extend ( {
343
+ click ( ) {
344
+ assert . ok ( true , 'click was fired' ) ;
345
+ } ,
346
+ } )
347
+ )
331
348
) ;
332
349
333
350
await render ( hbs `{{x-foo}}` ) ;
@@ -345,17 +362,15 @@ module('setupRenderingContext', function (hooks) {
345
362
346
363
this . owner . register (
347
364
'component:x-foo' ,
348
- Component . extend ( {
349
- actions : {
350
- clicked ( ) {
365
+ setComponentTemplate (
366
+ hbs `<button {{on 'click' this.clicked}}>Click me!</button>` ,
367
+
368
+ class extends Component {
369
+ clicked = ( ) => {
351
370
assert . ok ( true , 'click was fired' ) ;
352
- } ,
353
- } ,
354
- } )
355
- ) ;
356
- this . owner . register (
357
- 'template:components/x-foo' ,
358
- hbs `<button {{action 'clicked'}}>Click me!</button>`
371
+ } ;
372
+ }
373
+ )
359
374
) ;
360
375
361
376
await render ( hbs `{{x-foo}}` ) ;
@@ -371,10 +386,12 @@ module('setupRenderingContext', function (hooks) {
371
386
test ( 'can pass function to be used as a "closure action"' , async function ( assert ) {
372
387
assert . expect ( 2 ) ;
373
388
374
- this . owner . register ( 'component:x-foo' , Component . extend ( ) ) ;
375
389
this . owner . register (
376
- 'template:components/x-foo' ,
377
- hbs `<button onclick={{action @clicked}}>Click me!</button>`
390
+ 'component:x-foo' ,
391
+ setComponentTemplate (
392
+ hbs `<button {{on 'click' @clicked}}>Click me!</button>` ,
393
+ Component . extend ( )
394
+ )
378
395
) ;
379
396
380
397
this . set ( 'clicked' , ( ) => assert . ok ( true , 'action was triggered' ) ) ;
@@ -391,9 +408,12 @@ module('setupRenderingContext', function (hooks) {
391
408
test ( 'can pass function to be used as a "closure action" to a template only component' , async function ( assert ) {
392
409
assert . expect ( 2 ) ;
393
410
394
- let template = hbs `<button onclick={{action @clicked}}>Click me!</button>` ;
411
+ let template = hbs `<button onclick={{@clicked}}>Click me!</button>` ;
395
412
396
- this . owner . register ( 'template:components/x-foo' , template ) ;
413
+ this . owner . register (
414
+ 'component:x-foo' ,
415
+ setComponentTemplate ( template , class extends Component { } )
416
+ ) ;
397
417
398
418
this . set ( 'clicked' , ( ) => assert . ok ( true , 'action was triggered' ) ) ;
399
419
await render ( hbs `{{x-foo clicked=this.clicked}}` ) ;
@@ -408,8 +428,11 @@ module('setupRenderingContext', function (hooks) {
408
428
409
429
test ( 'can update a passed in argument with an <input>' , async function ( assert ) {
410
430
this . owner . register (
411
- 'template:components/my-input' ,
412
- hbs `{{input value=@value}}`
431
+ 'component:my-input' ,
432
+ setComponentTemplate (
433
+ hbs `{{input value=@value}}` ,
434
+ class extends Component { }
435
+ )
413
436
) ;
414
437
415
438
await render ( hbs `<MyInput @value={{this.value}} />` ) ;
@@ -436,8 +459,11 @@ module('setupRenderingContext', function (hooks) {
436
459
437
460
test ( 'it supports dom triggered focus events' , async function ( assert ) {
438
461
this . owner . register (
439
- 'template:components/x-input' ,
440
- hbs `<input onblur={{this.onBlur}} onfocusout={{this.onFocus}} />`
462
+ 'component:x-input' ,
463
+ setComponentTemplate (
464
+ hbs `<input onblur={{this.onBlur}} onfocusout={{this.onFocus}} />` ,
465
+ class extends Component { }
466
+ )
441
467
) ;
442
468
await render ( hbs `<XInput />` ) ;
443
469
@@ -463,17 +489,14 @@ module('setupRenderingContext', function (hooks) {
463
489
test ( 'two way bound arguments are updated' , async function ( assert ) {
464
490
this . owner . register (
465
491
'component:my-component' ,
466
- Component . extend ( {
467
- actions : {
468
- clicked ( ) {
492
+ setComponentTemplate (
493
+ hbs `<button {{on 'click' this.clicked}}>{{this.foo}}</button>` ,
494
+ class extends Component {
495
+ clicked = ( ) => {
469
496
this . set ( 'foo' , 'updated!' ) ;
470
- } ,
471
- } ,
472
- } )
473
- ) ;
474
- this . owner . register (
475
- 'template:components/my-component' ,
476
- hbs `<button {{action 'clicked'}}>{{this.foo}}</button>`
497
+ } ;
498
+ }
499
+ )
477
500
) ;
478
501
479
502
this . set ( 'foo' , 'original' ) ;
@@ -496,18 +519,15 @@ module('setupRenderingContext', function (hooks) {
496
519
test ( 'two way bound arguments are available after clearRender is called' , async function ( assert ) {
497
520
this . owner . register (
498
521
'component:my-component' ,
499
- Component . extend ( {
500
- actions : {
501
- clicked ( ) {
522
+ setComponentTemplate (
523
+ hbs `<button {{on 'click' this.clicked}}>{{this.foo}}</button>` ,
524
+ class extends Component {
525
+ clicked = ( ) => {
502
526
this . set ( 'foo' , 'updated!' ) ;
503
527
this . set ( 'bar' , 'updated bar!' ) ;
504
- } ,
505
- } ,
506
- } )
507
- ) ;
508
- this . owner . register (
509
- 'template:components/my-component' ,
510
- hbs `<button {{action 'clicked'}}>{{this.foo}}</button>`
528
+ } ;
529
+ }
530
+ )
511
531
) ;
512
532
513
533
// using two arguments here to ensure the two way binding
0 commit comments