1- import { moduleFor , RenderingTestCase , strip , runTask } from 'internal-test-helpers' ;
1+ import {
2+ moduleFor ,
3+ RenderingTestCase ,
4+ strip ,
5+ runTask ,
6+ expectDeprecation ,
7+ } from 'internal-test-helpers' ;
8+ import { DEPRECATIONS } from '../../../../deprecations' ;
29
310import { set } from '@ember/object' ;
411import { setComponentTemplate } from '@glimmer/manager' ;
@@ -57,7 +64,15 @@ class AbstractAppendTest extends RenderingTestCase {
5764 }
5865 componentsByName [ name ] = this ;
5966 pushHook ( 'init' ) ;
60- this . on ( 'init' , ( ) => pushHook ( 'on(init)' ) ) ;
67+ if ( ! DEPRECATIONS . DEPRECATE_EVENTED . isRemoved ) {
68+ expectDeprecation (
69+ ( ) => {
70+ this . on ( 'init' , ( ) => pushHook ( 'on(init)' ) ) ;
71+ } ,
72+ / E v e n t e d # o n ` i s d e p r e c a t e d / ,
73+ DEPRECATIONS . DEPRECATE_EVENTED . isEnabled
74+ ) ;
75+ }
6176 }
6277
6378 didReceiveAttrs ( ) {
@@ -145,26 +160,28 @@ class AbstractAppendTest extends RenderingTestCase {
145160 { parentValue : 1 , childValue : 1 , foo : 'zomg' , show : true }
146161 ) ;
147162
148- assert . deepEqual (
149- hooks ,
150- [
151- [ 'x-parent' , 'init' ] ,
152- [ 'x-parent' , 'on(init)' ] ,
153- [ 'x-parent' , 'didReceiveAttrs' ] ,
154- [ 'x-parent' , 'willRender' ] ,
155- [ 'x-parent' , 'willInsertElement' ] ,
156- [ 'x-child' , 'init' ] ,
157- [ 'x-child' , 'on(init)' ] ,
158- [ 'x-child' , 'didReceiveAttrs' ] ,
159- [ 'x-child' , 'willRender' ] ,
160- [ 'x-child' , 'willInsertElement' ] ,
161- [ 'x-child' , 'didInsertElement' ] ,
162- [ 'x-child' , 'didRender' ] ,
163- [ 'x-parent' , 'didInsertElement' ] ,
164- [ 'x-parent' , 'didRender' ] ,
165- ] ,
166- 'creation of x-parent'
167- ) ;
163+ let expectedCreationHooks = [
164+ [ 'x-parent' , 'init' ] ,
165+ [ 'x-parent' , 'on(init)' ] ,
166+ [ 'x-parent' , 'didReceiveAttrs' ] ,
167+ [ 'x-parent' , 'willRender' ] ,
168+ [ 'x-parent' , 'willInsertElement' ] ,
169+ [ 'x-child' , 'init' ] ,
170+ [ 'x-child' , 'on(init)' ] ,
171+ [ 'x-child' , 'didReceiveAttrs' ] ,
172+ [ 'x-child' , 'willRender' ] ,
173+ [ 'x-child' , 'willInsertElement' ] ,
174+ [ 'x-child' , 'didInsertElement' ] ,
175+ [ 'x-child' , 'didRender' ] ,
176+ [ 'x-parent' , 'didInsertElement' ] ,
177+ [ 'x-parent' , 'didRender' ] ,
178+ ] ;
179+
180+ if ( DEPRECATIONS . DEPRECATE_EVENTED . isRemoved ) {
181+ expectedCreationHooks = expectedCreationHooks . filter ( ( [ , hook ] ) => hook !== 'on(init)' ) ;
182+ }
183+
184+ assert . deepEqual ( hooks , expectedCreationHooks , 'creation of x-parent' ) ;
168185
169186 hooks . length = 0 ;
170187 runTask ( ( ) => this . rerender ( ) ) ;
@@ -298,7 +315,15 @@ class AbstractAppendTest extends RenderingTestCase {
298315 }
299316 componentsByName [ name ] = this ;
300317 pushHook ( 'init' ) ;
301- this . on ( 'init' , ( ) => pushHook ( 'on(init)' ) ) ;
318+ if ( ! DEPRECATIONS . DEPRECATE_EVENTED . isRemoved ) {
319+ expectDeprecation (
320+ ( ) => {
321+ this . on ( 'init' , ( ) => pushHook ( 'on(init)' ) ) ;
322+ } ,
323+ / E v e n t e d # o n ` i s d e p r e c a t e d / ,
324+ DEPRECATIONS . DEPRECATE_EVENTED . isEnabled
325+ ) ;
326+ }
302327 }
303328
304329 didReceiveAttrs ( ) {
@@ -381,15 +406,18 @@ class AbstractAppendTest extends RenderingTestCase {
381406 XParent = this . owner . factoryFor ( 'component:x-parent' ) ;
382407
383408 this . component = XParent . create ( { foo : 'zomg' } ) ;
384-
385- assert . deepEqual (
386- hooks ,
387- [
388- [ 'x-parent' , 'init' ] ,
389- [ 'x-parent' , 'on(init)' ] ,
390- ] ,
391- 'creation of x-parent'
392- ) ;
409+ if ( DEPRECATIONS . DEPRECATE_EVENTED . isRemoved ) {
410+ assert . deepEqual ( hooks , [ [ 'x-parent' , 'init' ] ] , 'creation of x-parent' ) ;
411+ } else {
412+ assert . deepEqual (
413+ hooks ,
414+ [
415+ [ 'x-parent' , 'init' ] ,
416+ [ 'x-parent' , 'on(init)' ] ,
417+ ] ,
418+ 'creation of x-parent'
419+ ) ;
420+ }
393421
394422 hooks . length = 0 ;
395423
@@ -401,7 +429,7 @@ class AbstractAppendTest extends RenderingTestCase {
401429 [ 'x-parent' , 'willInsertElement' ] ,
402430
403431 [ 'x-child' , 'init' ] ,
404- [ 'x-child' , 'on(init)' ] ,
432+ ! DEPRECATIONS . DEPRECATE_EVENTED . isRemoved && [ 'x-child' , 'on(init)' ] ,
405433 [ 'x-child' , 'didReceiveAttrs' ] ,
406434 [ 'x-child' , 'willRender' ] ,
407435 [ 'x-child' , 'willInsertElement' ] ,
@@ -411,7 +439,7 @@ class AbstractAppendTest extends RenderingTestCase {
411439
412440 [ 'x-parent' , 'didInsertElement' ] ,
413441 [ 'x-parent' , 'didRender' ] ,
414- ] ,
442+ ] . filter ( Boolean ) ,
415443 'appending of x-parent'
416444 ) ;
417445
0 commit comments