Skip to content

Commit 9502b09

Browse files
committed
chore(*): fixing leaking tests because of component ids
1 parent f11f36a commit 9502b09

File tree

9 files changed

+28
-6
lines changed

9 files changed

+28
-6
lines changed

angular.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@
191191
"zone.js/testing",
192192
"hammerjs"
193193
],
194+
"styles": [
195+
"src/styles/styles.scss"
196+
],
197+
"stylePreprocessorOptions": {
198+
"includePaths": [
199+
"node_modules"
200+
]
201+
},
194202
"tsConfig": "projects/igniteui-angular/tsconfig.spec.json",
195203
"karmaConfig": "projects/igniteui-angular/karma.conf.js"
196204
}

projects/igniteui-angular/karma.conf.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module.exports = function (config) {
99
frameworks: ['parallel', 'jasmine', '@angular-devkit/build-angular'],
1010
files: [
1111
{ pattern: '../../node_modules/hammerjs/hammer.min.js', watched: false },
12-
{ pattern: '../../node_modules/hammer-simulator/index.js', watched: false },
13-
{ pattern: './test.css', watched: false },
14-
{ pattern: '../../dist/igniteui-angular/styles/igniteui-angular.css', watched: false }
12+
{ pattern: '../../node_modules/hammer-simulator/index.js', watched: false }
1513
],
1614
plugins: [
1715
'karma-parallel',

projects/igniteui-angular/karma.watch.conf.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ module.exports = function (config) {
77
frameworks: ['jasmine', '@angular-devkit/build-angular'],
88
files: [
99
{ pattern: '../../node_modules/hammerjs/hammer.min.js', watched: false },
10-
{ pattern: '../../node_modules/hammer-simulator/index.js', watched: false },
11-
{ pattern: './test.css', watched: false },
12-
{ pattern: '../../dist/igniteui-angular/styles/igniteui-angular.css', watched: false }
10+
{ pattern: '../../node_modules/hammer-simulator/index.js', watched: false }
1311
],
1412
plugins: [
1513
'karma-jasmine',

projects/igniteui-angular/src/lib/checkbox/checkbox.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ describe('IgxCheckbox', () => {
196196
const fixture = TestBed.createComponent(IgxCheckboxComponent);
197197

198198
const checkboxInstance = fixture.componentInstance;
199+
// For test fixture destroy
200+
checkboxInstance.id = "root1";
199201
checkboxInstance.disabled = true;
200202
const nativeCheckbox = checkboxInstance.nativeInput.nativeElement as HTMLInputElement;
201203
const nativeLabel = checkboxInstance.nativeLabel.nativeElement as HTMLLabelElement;

projects/igniteui-angular/src/lib/chips/chip.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ describe('IgxChip', () => {
140140
it('should change chip variant', () => {
141141
const fixture = TestBed.createComponent(IgxChipComponent);
142142
const igxChip = fixture.componentInstance;
143+
// For test fixture destroy
144+
igxChip.id = "root1";
143145

144146
igxChip.variant = 'danger';
145147

@@ -368,6 +370,7 @@ describe('IgxChip', () => {
368370

369371
expect(secondChipComp.selectedChanging.emit).not.toHaveBeenCalled();
370372
expect(secondChipComp.selectedChanged.emit).not.toHaveBeenCalled();
373+
console.log('id', secondChipComp.id);
371374
});
372375
});
373376

projects/igniteui-angular/src/lib/progressbar/circularbar.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ describe('IgxCircularProgressBarComponent', () => {
2020

2121
fixture = TestBed.createComponent(IgxCircularProgressBarComponent);
2222
progress = fixture.componentInstance;
23+
// For test fixture destroy
24+
progress.id = "root1";
2325
fixture.detectChanges();
2426
circularBar = fixture.debugElement.nativeElement;
2527
});
@@ -38,6 +40,8 @@ describe('IgxCircularProgressBarComponent', () => {
3840
fixture.detectChanges();
3941

4042
expect(progress.id).toBe(customId);
43+
// For test fixture destroy
44+
progress.id = "root1";
4145
});
4246

4347
it('should correctly toggle the indeterminate mode', () => {

projects/igniteui-angular/src/lib/progressbar/linearbar.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ describe('IgxLinearProgressBarComponent', () => {
1616
beforeEach(() => {
1717
fixture = TestBed.createComponent(IgxLinearProgressBarComponent);
1818
progress = fixture.componentInstance;
19+
// For test fixture destroy
20+
progress.id = "root1";
1921
fixture.detectChanges();
2022
linearBar = fixture.debugElement.nativeElement;
2123
});
@@ -138,6 +140,8 @@ describe('IgxLinearProgressBarComponent', () => {
138140

139141
expect(progress.id).toBe(customId);
140142
expect(linearBar.id).toBe(customId);
143+
// For test fixture destroy
144+
progress.id = "root1";
141145
});
142146

143147
it('should apply type-specific classes correctly', () => {

projects/igniteui-angular/src/lib/switch/switch.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ describe('IgxSwitch', () => {
154154
it('Disabled state', () => {
155155
const fixture = TestBed.createComponent(IgxSwitchComponent);
156156
const switchInstance = fixture.componentInstance;
157+
switchInstance.id = "root1";
157158
switchInstance.disabled = true;
158159
const nativeCheckbox = switchInstance.nativeInput.nativeElement as HTMLInputElement;
159160
const nativeLabel = switchInstance.nativeLabel.nativeElement;

projects/igniteui-angular/src/lib/toast/toast.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ describe('IgxToast', () => {
3737
beforeEach(() => {
3838
fixture = TestBed.createComponent(IgxToastComponent);
3939
toast = fixture.componentInstance;
40+
// For test fixture destroy
41+
toast.id = "root1";
4042
fixture.detectChanges();
4143
});
4244

@@ -49,6 +51,8 @@ describe('IgxToast', () => {
4951

5052
expect(toast.id).toBe('customToast');
5153
expect(toast.element.id).toContain('customToast');
54+
// For test fixture destroy
55+
toast.id = "root1";
5256
});
5357

5458
it('should properly toggle and emit isVisibleChange', fakeAsync(() => {

0 commit comments

Comments
 (0)