@@ -140,4 +140,96 @@ describe('IgxChartMenuComponent', () => {
140140 expect ( component . isConfigAreaExpanded ) . toBeFalse ( ) ;
141141 } ) ;
142142 } ) ;
143+
144+ describe ( 'ngAfterViewInit' , ( ) => {
145+ it ( 'should create a ResizeObserver and call createChart when currentChartType and chartDirective are set' , ( ) => {
146+ const factorySpy = jasmine . createSpy ( 'chartFactory' ) ;
147+ component . chartDirective = { chartFactory : factorySpy } ;
148+ component . chartArea = { clear : ( ) => { } } as any ;
149+ component . currentChartType = 'Pie' ;
150+
151+ component . ngAfterViewInit ( ) ;
152+
153+ expect ( factorySpy ) . toHaveBeenCalledWith ( 'Pie' , component . chartArea ) ;
154+ } ) ;
155+
156+ it ( 'should not call createChart when currentChartType is not set' , ( ) => {
157+ const factorySpy = jasmine . createSpy ( 'chartFactory' ) ;
158+ component . chartDirective = { chartFactory : factorySpy } ;
159+ component . chartArea = { clear : ( ) => { } } as any ;
160+ component . currentChartType = undefined ;
161+
162+ component . ngAfterViewInit ( ) ;
163+
164+ expect ( factorySpy ) . not . toHaveBeenCalled ( ) ;
165+ } ) ;
166+
167+ it ( 'should not call createChart when chartDirective is not set' , ( ) => {
168+ component . chartDirective = undefined ;
169+ component . currentChartType = 'Pie' ;
170+
171+ expect ( ( ) => component . ngAfterViewInit ( ) ) . not . toThrow ( ) ;
172+ } ) ;
173+ } ) ;
174+
175+ describe ( 'ngOnDestroy' , ( ) => {
176+ it ( 'should disconnect the contentObserver if it exists' , ( ) => {
177+ component . ngAfterViewInit ( ) ;
178+ const observer = ( component as any ) . contentObserver ;
179+ const disconnectSpy = spyOn ( observer , 'disconnect' ) ;
180+
181+ component . ngOnDestroy ( ) ;
182+
183+ expect ( disconnectSpy ) . toHaveBeenCalled ( ) ;
184+ } ) ;
185+
186+ it ( 'should complete the chartDialogResizeNotify subject' , ( ) => {
187+ const completeSpy = spyOn ( component . chartDialogResizeNotify , 'complete' ) ;
188+
189+ component . ngOnDestroy ( ) ;
190+
191+ expect ( completeSpy ) . toHaveBeenCalled ( ) ;
192+ } ) ;
193+
194+ it ( 'should not throw when contentObserver is not set' , ( ) => {
195+ ( component as any ) . contentObserver = undefined ;
196+
197+ expect ( ( ) => component . ngOnDestroy ( ) ) . not . toThrow ( ) ;
198+ } ) ;
199+ } ) ;
200+
201+ describe ( 'createChart title formatting' , ( ) => {
202+ beforeEach ( ( ) => {
203+ component . chartDirective = { chartFactory : ( ) => { } } ;
204+ component . chartArea = { clear : ( ) => { } } as any ;
205+ } ) ;
206+
207+ it ( 'should replace only the first comma with a space for two-word types' , ( ) => {
208+ component . createChart ( 'ColumnGrouped' ) ;
209+ expect ( component . title ) . toBe ( 'Column Grouped' ) ;
210+ } ) ;
211+
212+ it ( 'should handle chart types with numbers like Column100Stacked' , ( ) => {
213+ component . createChart ( 'Column100Stacked' ) ;
214+ // split on uppercase: 'Column100','Stacked' → 'Column100 Stacked'
215+ expect ( component . title ) . toBe ( 'Column100 Stacked' ) ;
216+ } ) ;
217+
218+ it ( 'should handle single-word chart types' , ( ) => {
219+ component . createChart ( 'Pie' ) ;
220+ expect ( component . title ) . toBe ( 'Pie' ) ;
221+ } ) ;
222+
223+ it ( 'should handle three-word chart types like ScatterBubbleChart' , ( ) => {
224+ component . createChart ( 'ScatterBubbleChart' ) ;
225+ // 'Scatter,Bubble,Chart'.replace(',', ' ') → 'Scatter Bubble,Chart'
226+ expect ( component . title ) . toBe ( 'Scatter Bubble,Chart' ) ;
227+ } ) ;
228+ } ) ;
229+
230+ describe ( 'images' , ( ) => {
231+ it ( 'should initialize images from charts module' , ( ) => {
232+ expect ( component . images ) . toBeDefined ( ) ;
233+ } ) ;
234+ } ) ;
143235} ) ;
0 commit comments