@@ -10,7 +10,7 @@ import {
1010} from '@angular/core/testing' ;
1111
1212import {
13- DxChartModule , DxChartComponent
13+ DxChartModule , DxChartComponent , DxScrollViewModule
1414} from 'devextreme-angular' ;
1515
1616@Component ( {
@@ -23,13 +23,18 @@ class TestContainerComponent {
2323 } ] ;
2424 @ViewChild ( DxChartComponent ) chart : DxChartComponent ;
2525 dataSource = [ ] ;
26+ disposed = false ;
2627 commonSeriesSettings = {
2728 argumentField : undefined
2829 } ;
2930 seriesAsArray = [ ] ;
3031 seriesAsObject = {
3132 valueField : undefined
3233 } ;
34+
35+ onDisposing ( ) {
36+ this . disposed = true ;
37+ }
3338}
3439
3540describe ( 'DxChart' , ( ) => {
@@ -38,7 +43,7 @@ describe('DxChart', () => {
3843 TestBed . configureTestingModule (
3944 {
4045 declarations : [ TestContainerComponent ] ,
41- imports : [ DxChartModule ]
46+ imports : [ DxChartModule , DxScrollViewModule ]
4247 } ) ;
4348 } ) ;
4449
@@ -62,7 +67,7 @@ describe('DxChart', () => {
6267 it ( 'should not repainting twice in change detection cycle after applying options directly' , ( ) => {
6368 TestBed . overrideComponent ( TestContainerComponent , {
6469 set : {
65- template : `<dx-chart
70+ template : `<dx-chart
6671 [dataSource]="dataSource"
6772 [series]="seriesAsArray"
6873 [commonSeriesSettings]="{ argumentField: 'name' }"
@@ -92,7 +97,7 @@ describe('DxChart', () => {
9297 it ( 'should not repainting twice in change detection cycle after detect changes in arrays' , ( ) => {
9398 TestBed . overrideComponent ( TestContainerComponent , {
9499 set : {
95- template : `<dx-chart
100+ template : `<dx-chart
96101 [dataSource]="dataSource"
97102 [series]="seriesAsArray"
98103 [commonSeriesSettings]="{ argumentField: 'name' }"
@@ -145,4 +150,31 @@ describe('DxChart', () => {
145150
146151 expect ( instance . option ( 'argumentAxis.strips[0].label.text' ) ) . toBe ( 'label2' ) ;
147152 } ) ;
153+
154+ it ( 'should remove component by dispose method' , ( ) => {
155+ TestBed . overrideComponent ( TestContainerComponent , {
156+ set : {
157+ template : `
158+ <dx-chart [dataSource]="[{ ID: 1, Text: 'A', Value: '2' }]" (onDisposing)='onDisposing()'>
159+ <dxi-series argumentField='Text' valueField='Value' type='bar' color='#f9ce2d'>
160+ <dxo-label [visible]='false'> </dxo-label>
161+ </dxi-series>
162+ </dx-chart>`
163+ }
164+ } ) ;
165+
166+ jasmine . clock ( ) . uninstall ( ) ;
167+ jasmine . clock ( ) . install ( ) ;
168+ let fixture = TestBed . createComponent ( TestContainerComponent ) ;
169+ fixture . detectChanges ( ) ;
170+
171+ const testComponent = fixture . componentInstance ;
172+ const instance = testComponent . chart . instance ;
173+ instance . dispose ( ) ;
174+ fixture . detectChanges ( ) ;
175+ fixture . destroy ( ) ;
176+ expect ( testComponent . disposed ) ;
177+ jasmine . clock ( ) . uninstall ( ) ;
178+
179+ } ) ;
148180} ) ;
0 commit comments