Skip to content

Commit 932be7e

Browse files
author
Konstantin Dinev
committed
test(extras): adding more coverage
1 parent 2a1d093 commit 932be7e

10 files changed

Lines changed: 635 additions & 87 deletions

File tree

package-lock.json

Lines changed: 0 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start:elements": "ng serve --project igniteui-angular-elements",
88
"start:performance": "ng serve --project igniteui-angular-performance",
99
"build": "npm run build:lib && npm run build:elements && npm run build:extras && npm run build:schematics && npm run build:migrations && npm run build:i18n",
10-
"test": "ng test igniteui-angular",
10+
"test": "npm run test:lib && npm run test:styles && npm run test:schematics && npm run test:i18n && npm run test:extras && npm run test:elements",
1111
"lint": "ng lint",
1212
"e2e": "ng e2e",
1313
"test:lib": "ng test igniteui-angular --watch=false --no-progress --code-coverage",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
4+
# compiled output
5+
/dist
6+
/tmp
7+
/out-tsc
8+
9+
.angular/*
10+
11+
# dependencies
12+
/node_modules
13+
14+
# IDEs and editors
15+
/.idea
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# IDE - VSCode/VS
24+
.vscode/*
25+
.vs/*
26+
!.vscode/settings.json
27+
!.vscode/tasks.json
28+
!.vscode/launch.json
29+
!.vscode/extensions.json
30+
31+
# misc
32+
/.angular/cache
33+
/.sass-cache
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
npm-debug.log
38+
yarn-error.log
39+
testem.log
40+
/typings
41+
TESTS-**.xml
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db
46+
47+
src/**/*.js
48+
src/**/*.js.map
49+
src/**/*.css.map
50+
51+
# Typedoc and SassDoc Themes
52+
extras/sassdoc/**/*
53+
extras/docs/themes/typedoc/bin
54+
extras/docs/themes/sassdoc/node_modules
55+
extras/docs/themes/sassdoc/sassdoc/*
56+
57+
# Localization sources
58+
i18nRepo

projects/igniteui-angular-extras/src/lib/context-menu/chart-dialog/chart-dialog.component.spec.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)