@@ -15,6 +15,7 @@ import {
1515import DxList from 'devextreme/ui/list' ;
1616
1717import {
18+ DxButtonModule ,
1819 DxListModule ,
1920 DxListComponent
2021} from '../../../dist' ;
@@ -325,8 +326,7 @@ describe('DxList', () => {
325326 expect ( instance . element ( ) . find ( '.dx-item-content' ) . eq ( 0 ) . text ( ) ) . toBe ( 'testTemplate' ) ;
326327 } ) ) ;
327328
328-
329- it ( 'should destroy all components inside template' , ( ) => {
329+ it ( 'should destroy angular components inside template' , ( ) => {
330330 let destroyed = false ;
331331 @Component ( {
332332 selector : 'destroyable-component' ,
@@ -363,4 +363,76 @@ describe('DxList', () => {
363363
364364 expect ( destroyed ) . toBe ( true ) ;
365365 } ) ;
366+
367+ it ( 'should destroy devextreme components inside template' , ( ) => {
368+ @Component ( {
369+ selector : 'test-container-component' ,
370+ template : ''
371+ } )
372+ class TestContainerComponent {
373+ items = [ 0 ] ;
374+ buttonDestroyed = false ;
375+ listVisible = true ;
376+ }
377+
378+ TestBed . configureTestingModule ( {
379+ declarations : [ TestContainerComponent ] ,
380+ imports : [ DxButtonModule , DxListModule ]
381+ } ) ;
382+
383+ TestBed . overrideComponent ( TestContainerComponent , {
384+ set : {
385+ template : `
386+ <dx-list *ngIf="listVisible" [items]="items">
387+ <div *dxTemplate="let item of 'item'">
388+ <dx-button text="Test" (onDisposing)="buttonDestroyed = true"></dx-button>
389+ </div>
390+ </dx-list>
391+ `
392+ }
393+ } ) ;
394+
395+ let fixture = TestBed . createComponent ( TestContainerComponent ) ;
396+ fixture . detectChanges ( ) ;
397+
398+ fixture . componentInstance . listVisible = false ;
399+ fixture . detectChanges ( ) ;
400+
401+ expect ( fixture . componentInstance . buttonDestroyed ) . toBe ( true ) ;
402+ } ) ;
403+
404+ it ( 'should destroy devextreme components in template root correctly' , ( ) => {
405+ @Component ( {
406+ selector : 'test-container-component' ,
407+ template : ''
408+ } )
409+ class TestContainerComponent {
410+ items = [ 0 ] ;
411+ buttonDestroyed = false ;
412+ listVisible = true ;
413+ }
414+
415+ TestBed . configureTestingModule ( {
416+ declarations : [ TestContainerComponent ] ,
417+ imports : [ DxButtonModule , DxListModule ]
418+ } ) ;
419+
420+ TestBed . overrideComponent ( TestContainerComponent , {
421+ set : {
422+ template : `
423+ <dx-list *ngIf="listVisible" [items]="items">
424+ <dx-button text="Test" (onDisposing)="buttonDestroyed = true" *dxTemplate="let item of 'item'"></dx-button>
425+ </dx-list>
426+ `
427+ }
428+ } ) ;
429+
430+ let fixture = TestBed . createComponent ( TestContainerComponent ) ;
431+ fixture . detectChanges ( ) ;
432+
433+ fixture . componentInstance . listVisible = false ;
434+ fixture . detectChanges ( ) ;
435+
436+ expect ( fixture . componentInstance . buttonDestroyed ) . toBe ( true ) ;
437+ } ) ;
366438} ) ;
0 commit comments