Skip to content

Commit 6512523

Browse files
authored
Merge pull request #6588 from IgniteUI/SKrastev/refactor-forOf-tests
test(forOf): Bring back separate testing module configurations for each describe.
2 parents 2292e93 + 4a14ef7 commit 6512523

File tree

1 file changed

+103
-25
lines changed

1 file changed

+103
-25
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts

Lines changed: 103 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,19 @@ describe('IgxForOf directive -', () => {
4040
beforeAll(() => {
4141
dg = new DataGenerator();
4242
});
43-
configureTestSuite();
44-
beforeEach(async(() => {
45-
TestBed.configureTestingModule({
46-
declarations: [
47-
TestIgxForOfDirective,
48-
EmptyVirtualComponent,
49-
HorizontalVirtualComponent,
50-
VerticalVirtualNoDataComponent,
51-
VerticalVirtualComponent,
52-
VirtualComponent,
53-
VirtualVariableSizeComponent,
54-
RemoteVirtualizationComponent,
55-
RemoteVirtCountComponent,
56-
NoWidthAndHeightComponent,
57-
LocalVariablesComponent
58-
],
59-
imports: [IgxForOfModule],
60-
providers: [{ provide: NgZone, useFactory: () => zone = new TestNgZone() }]
61-
}).compileComponents();
62-
}));
6343

6444
describe('empty virtual component', () => {
45+
configureTestSuite();
46+
beforeEach(async(() => {
47+
TestBed.configureTestingModule({
48+
declarations: [
49+
TestIgxForOfDirective,
50+
EmptyVirtualComponent
51+
],
52+
imports: [IgxForOfModule]
53+
}).compileComponents();
54+
}));
55+
6556
it('should initialize empty directive', () => {
6657
const fix = TestBed.createComponent(EmptyVirtualComponent);
6758
fix.detectChanges();
@@ -73,6 +64,18 @@ describe('IgxForOf directive -', () => {
7364
describe('horizontal virtual component', () => {
7465
let fix: ComponentFixture<HorizontalVirtualComponent>;
7566

67+
configureTestSuite();
68+
beforeEach(async(() => {
69+
TestBed.configureTestingModule({
70+
declarations: [
71+
TestIgxForOfDirective,
72+
HorizontalVirtualComponent
73+
],
74+
imports: [IgxForOfModule],
75+
providers: [{ provide: NgZone, useFactory: () => zone = new TestNgZone() }]
76+
}).compileComponents();
77+
}));
78+
7679
beforeEach(() => {
7780
fix = TestBed.createComponent(HorizontalVirtualComponent);
7881
dg.generateData(300, 5, fix.componentInstance);
@@ -158,23 +161,31 @@ describe('IgxForOf directive -', () => {
158161
fix.detectChanges();
159162

160163
fix.componentInstance.scrollLeft(50);
161-
162164
fix.detectChanges();
163165

164166
expect(parseInt(displayContainer.style.left, 10)).toEqual(-50);
165167

166-
fix.componentInstance.cols = [
167-
{ field: '1', width: 100 }
168-
];
168+
fix.componentInstance.cols = [{ field: '1', width: 100 }];
169169
fix.detectChanges();
170170

171171
expect(parseInt(displayContainer.style.left, 10)).toEqual(0);
172-
173172
});
174173
});
175174

176175
describe('vertical virtual component', () => {
177176
let fix: ComponentFixture<VerticalVirtualComponent>;
177+
configureTestSuite();
178+
beforeEach(async(() => {
179+
TestBed.configureTestingModule({
180+
declarations: [
181+
TestIgxForOfDirective,
182+
VerticalVirtualNoDataComponent,
183+
VerticalVirtualComponent
184+
],
185+
imports: [IgxForOfModule],
186+
providers: [{ provide: NgZone, useFactory: () => zone = new TestNgZone() }]
187+
}).compileComponents();
188+
}));
178189

179190
beforeEach(() => {
180191
fix = TestBed.createComponent(VerticalVirtualComponent);
@@ -315,6 +326,18 @@ describe('IgxForOf directive -', () => {
315326
describe('vertical and horizontal virtual component', () => {
316327
let fix: ComponentFixture<VirtualComponent>;
317328

329+
configureTestSuite();
330+
beforeEach(async(() => {
331+
TestBed.configureTestingModule({
332+
declarations: [
333+
TestIgxForOfDirective,
334+
VirtualComponent
335+
],
336+
imports: [IgxForOfModule],
337+
providers: [{ provide: NgZone, useFactory: () => zone = new TestNgZone() }]
338+
}).compileComponents();
339+
}));
340+
318341
beforeEach(() => {
319342
fix = TestBed.createComponent(VirtualComponent);
320343
dg.generateData300x50000(fix.componentInstance);
@@ -880,6 +903,17 @@ describe('IgxForOf directive -', () => {
880903
});
881904

882905
describe('variable size component', () => {
906+
configureTestSuite();
907+
beforeEach(async(() => {
908+
TestBed.configureTestingModule({
909+
declarations: [
910+
TestIgxForOfDirective,
911+
VirtualVariableSizeComponent
912+
],
913+
imports: [IgxForOfModule]
914+
}).compileComponents();
915+
}));
916+
883917
it('should update display container classes when content state changes from virtualized to non-virtualzied.', () => {
884918
const fix = TestBed.createComponent(VirtualVariableSizeComponent);
885919
fix.detectChanges();
@@ -915,6 +949,17 @@ describe('IgxForOf directive -', () => {
915949
});
916950

917951
describe('remote virtual component', () => {
952+
configureTestSuite();
953+
beforeEach(async(() => {
954+
TestBed.configureTestingModule({
955+
declarations: [
956+
TestIgxForOfDirective,
957+
RemoteVirtualizationComponent
958+
],
959+
imports: [IgxForOfModule]
960+
}).compileComponents();
961+
}));
962+
918963
it('should allow remote virtualization', async () => {
919964
const fix = TestBed.createComponent(RemoteVirtualizationComponent);
920965
fix.componentRef.hostView.detectChanges();
@@ -946,6 +991,17 @@ describe('IgxForOf directive -', () => {
946991
});
947992

948993
describe('remote virtual component with specified igxForTotalItemCount', () => {
994+
configureTestSuite();
995+
beforeEach(async(() => {
996+
TestBed.configureTestingModule({
997+
declarations: [
998+
TestIgxForOfDirective,
999+
RemoteVirtCountComponent
1000+
],
1001+
imports: [IgxForOfModule]
1002+
}).compileComponents();
1003+
}));
1004+
9491005
it('should apply remote virtualization correctly', async () => {
9501006
const fix = TestBed.createComponent(RemoteVirtCountComponent);
9511007
fix.componentRef.hostView.detectChanges();
@@ -977,6 +1033,17 @@ describe('IgxForOf directive -', () => {
9771033
});
9781034

9791035
describe('no width and height component', () => {
1036+
configureTestSuite();
1037+
beforeEach(async(() => {
1038+
TestBed.configureTestingModule({
1039+
declarations: [
1040+
TestIgxForOfDirective,
1041+
NoWidthAndHeightComponent
1042+
],
1043+
imports: [IgxForOfModule]
1044+
}).compileComponents();
1045+
}));
1046+
9801047
it('should use itemSize when no width or height are provided', () => {
9811048
const fix = TestBed.createComponent(NoWidthAndHeightComponent);
9821049
fix.componentRef.hostView.detectChanges();
@@ -990,6 +1057,17 @@ describe('IgxForOf directive -', () => {
9901057
});
9911058

9921059
describe('even odd first last functions', () => {
1060+
configureTestSuite();
1061+
beforeEach(async(() => {
1062+
TestBed.configureTestingModule({
1063+
declarations: [
1064+
TestIgxForOfDirective,
1065+
LocalVariablesComponent
1066+
],
1067+
imports: [IgxForOfModule]
1068+
}).compileComponents();
1069+
}));
1070+
9931071
it('should differentiate even odd items', () => {
9941072
const fix = TestBed.createComponent(LocalVariablesComponent);
9951073
fix.detectChanges();

0 commit comments

Comments
 (0)