Skip to content

Commit d91a277

Browse files
committed
refactor(grid): migrating tests to standalone #12698
1 parent a03ec4b commit d91a277

23 files changed

+580
-900
lines changed

projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, ViewChild, OnInit, NgZone, DebugElement } from '@angular/core';
22
import { TestBed, fakeAsync } from '@angular/core/testing';
33
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
4-
import { IgxColumnComponent, IgxGridComponent, IgxGridModule, IGridCellEventArgs } from './public_api';
4+
import { IgxColumnComponent, IgxGridComponent, IGridCellEventArgs } from './public_api';
55
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
66
import { configureTestSuite } from '../../test-utils/configure-suite';
77
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
@@ -12,6 +12,7 @@ import { VirtualGridComponent, NoScrollsComponent,
1212
import { GridFunctions } from '../../test-utils/grid-functions.spec';
1313
import { TestNgZone } from '../../test-utils/helper-utils.spec';
1414
import { CellType } from '../common/grid.interface';
15+
import { NgFor } from '@angular/common';
1516

1617
describe('IgxGrid - Cell component #grid', () => {
1718

@@ -24,9 +25,8 @@ describe('IgxGrid - Cell component #grid', () => {
2425

2526
configureTestSuite((() => {
2627
return TestBed.configureTestingModule({
27-
declarations: [NoScrollsComponent],
28-
imports: [NoopAnimationsModule, IgxGridModule]
29-
});
28+
imports: [NoopAnimationsModule, NoScrollsComponent]
29+
});
3030
}));
3131

3232
beforeEach(() => {
@@ -158,10 +158,9 @@ describe('IgxGrid - Cell component #grid', () => {
158158

159159
configureTestSuite((() => {
160160
return TestBed.configureTestingModule({
161-
declarations: [VirtualGridComponent],
162-
imports: [NoopAnimationsModule, IgxGridModule],
163-
providers: [{ provide: NgZone, useFactory: () => new TestNgZone() }]
164-
});
161+
imports: [NoopAnimationsModule, VirtualGridComponent],
162+
providers: [{ provide: NgZone, useFactory: () => new TestNgZone() }]
163+
});
165164
}));
166165

167166
beforeEach(fakeAsync(() => {
@@ -272,9 +271,8 @@ describe('IgxGrid - Cell component #grid', () => {
272271
describe('iOS tests', () => {
273272
configureTestSuite((() => {
274273
return TestBed.configureTestingModule({
275-
declarations: [NoScrollsComponent],
276-
imports: [NoopAnimationsModule, IgxGridModule]
277-
});
274+
imports: [NoopAnimationsModule, NoScrollsComponent]
275+
});
278276
}));
279277

280278
it('Should not attach doubletap handler for non-iOS', () => {
@@ -329,9 +327,8 @@ describe('IgxGrid - Cell component #grid', () => {
329327
describe('No column widths', () => {
330328
configureTestSuite((() => {
331329
return TestBed.configureTestingModule({
332-
declarations: [NoColumnWidthGridComponent],
333-
imports: [NoopAnimationsModule, IgxGridModule]
334-
});
330+
imports: [NoopAnimationsModule, NoColumnWidthGridComponent]
331+
});
335332
}));
336333

337334
it('should not make last column width 0 when no column width is set', () => {
@@ -348,8 +345,8 @@ describe('IgxGrid - Cell component #grid', () => {
348345
describe('Cells styles', () => {
349346
configureTestSuite((() => {
350347
return TestBed.configureTestingModule({
351-
imports: [NoopAnimationsModule, IgxGridModule, ConditionalCellStyleTestComponent]
352-
});
348+
imports: [NoopAnimationsModule, ConditionalCellStyleTestComponent]
349+
});
353350
}));
354351

355352
it('should be able to conditionally style cells', fakeAsync(() => {
@@ -378,9 +375,8 @@ describe('IgxGrid - Cell component #grid', () => {
378375
describe('Cell properties', () => {
379376
configureTestSuite((() => {
380377
return TestBed.configureTestingModule({
381-
declarations: [IgxGridDateTimeColumnComponent],
382-
imports: [NoopAnimationsModule, IgxGridModule]
383-
});
378+
imports: [NoopAnimationsModule, IgxGridDateTimeColumnComponent]
379+
});
384380
}));
385381

386382
it('verify that value of the cell title is correctly', fakeAsync(() => {
@@ -423,7 +419,7 @@ describe('IgxGrid - Cell component #grid', () => {
423419
</igx-grid>`,
424420
styleUrls: ['../../test-utils/grid-cell-style-testing.scss'],
425421
standalone: true,
426-
imports: [IgxGridModule]
422+
imports: [IgxGridComponent, IgxColumnComponent, NgFor]
427423
})
428424
export class ConditionalCellStyleTestComponent implements OnInit {
429425
@ViewChild('grid', { static: true }) public grid: IgxGridComponent;

projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { TestBed, ComponentFixture, waitForAsync, fakeAsync, tick } from '@angular/core/testing';
2-
import { IgxGridModule } from './grid.module';
32
import { IgxGridComponent } from './grid.component';
43
import { DebugElement, QueryList } from '@angular/core';
54
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -34,24 +33,23 @@ describe('IgxGrid - multi-column headers #grid', () => {
3433

3534
beforeAll(waitForAsync(() => {
3635
TestBed.configureTestingModule({
37-
declarations: [OneGroupOneColGridComponent,
38-
OneGroupThreeColsGridComponent,
39-
BlueWhaleGridComponent,
40-
ColumnGroupTestComponent,
41-
ColumnGroupFourLevelTestComponent,
42-
ThreeGroupsThreeColumnsGridComponent,
43-
NestedColGroupsGridComponent,
44-
StegosaurusGridComponent,
45-
OneColPerGroupGridComponent,
46-
NestedColumnGroupsGridComponent,
47-
DynamicGridComponent,
48-
NestedColGroupsWithTemplatesGridComponent,
49-
DynamicColGroupsGridComponent],
50-
imports: [
51-
NoopAnimationsModule,
52-
IgxGridModule
53-
]
54-
})
36+
imports: [
37+
NoopAnimationsModule,
38+
OneGroupOneColGridComponent,
39+
OneGroupThreeColsGridComponent,
40+
BlueWhaleGridComponent,
41+
ColumnGroupTestComponent,
42+
ColumnGroupFourLevelTestComponent,
43+
ThreeGroupsThreeColumnsGridComponent,
44+
NestedColGroupsGridComponent,
45+
StegosaurusGridComponent,
46+
OneColPerGroupGridComponent,
47+
NestedColumnGroupsGridComponent,
48+
DynamicGridComponent,
49+
NestedColGroupsWithTemplatesGridComponent,
50+
DynamicColGroupsGridComponent
51+
]
52+
})
5553
.compileComponents();
5654
}));
5755

projects/igniteui-angular/src/lib/grids/grid/column-hiding.spec.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { DebugElement } from '@angular/core';
33
import { TestBed, fakeAsync, tick, ComponentFixture } from '@angular/core/testing';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5-
import { IgxGridModule } from './public_api';
65
import { IgxGridComponent } from './grid.component';
76
import { ColumnHidingTestComponent, ColumnGroupsHidingTestComponent } from '../../test-utils/grid-base-components.spec';
87
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
@@ -15,7 +14,6 @@ import { SortingDirection } from '../../data-operations/sorting-strategy';
1514

1615
describe('Column Hiding UI #grid', () => {
1716

18-
1917
let fix: ComponentFixture<ColumnHidingTestComponent>;
2018
let grid: IgxGridComponent;
2119
let columnChooser: IgxColumnActionsComponent;
@@ -27,13 +25,12 @@ describe('Column Hiding UI #grid', () => {
2725

2826
configureTestSuite((() => {
2927
return TestBed.configureTestingModule({
30-
declarations: [ColumnHidingTestComponent,
31-
ColumnGroupsHidingTestComponent],
32-
imports: [
33-
NoopAnimationsModule,
34-
IgxGridModule
35-
]
36-
});
28+
imports: [
29+
NoopAnimationsModule,
30+
ColumnHidingTestComponent,
31+
ColumnGroupsHidingTestComponent
32+
]
33+
});
3734
}));
3835

3936
describe('Basic', () => {

projects/igniteui-angular/src/lib/grids/grid/column-moving.spec.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { TestBed, fakeAsync, tick } from '@angular/core/testing';
33
import { FormsModule } from '@angular/forms';
44
import { By } from '@angular/platform-browser';
55
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
6-
import { IgxGridModule } from './public_api';
76
import { IgxColumnGroupComponent } from '../columns/column-group.component';
87
import { IgxInputDirective } from '../../directives/input/input.directive';
98
import {
@@ -28,16 +27,15 @@ describe('IgxGrid - Column Moving #grid', () => {
2827
let fixture; let grid: IgxGridComponent;
2928
configureTestSuite((() => {
3029
return TestBed.configureTestingModule({
31-
declarations: [MovableColumnsComponent,
32-
MovableTemplatedColumnsComponent,
33-
MovableColumnsLargeComponent,
34-
MultiColumnHeadersComponent],
35-
imports: [
36-
FormsModule,
37-
NoopAnimationsModule,
38-
IgxGridModule
39-
]
40-
});
30+
imports: [
31+
FormsModule,
32+
NoopAnimationsModule,
33+
MovableColumnsComponent,
34+
MovableTemplatedColumnsComponent,
35+
MovableColumnsLargeComponent,
36+
MultiColumnHeadersComponent
37+
]
38+
});
4139
}));
4240

4341
describe('', () => {

projects/igniteui-angular/src/lib/grids/grid/column-pinning.spec.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { DebugElement } from '@angular/core';
33
import { TestBed, waitForAsync, ComponentFixture } from '@angular/core/testing';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { IgxGridComponent } from './grid.component';
6-
import { IgxGridModule } from './public_api';
76
import {
87
ColumnPinningTestComponent,
98
ColumnGroupsPinningTestComponent,
@@ -28,14 +27,13 @@ describe('Column Pinning UI #grid', () => {
2827

2928
beforeAll(waitForAsync(() => {
3029
TestBed.configureTestingModule({
31-
declarations: [ColumnPinningTestComponent,
32-
ColumnGroupsPinningTestComponent,
33-
ColumnPinningWithTemplateTestComponent],
34-
imports: [
35-
NoopAnimationsModule,
36-
IgxGridModule
37-
]
38-
}).compileComponents();
30+
imports: [
31+
NoopAnimationsModule,
32+
ColumnPinningTestComponent,
33+
ColumnGroupsPinningTestComponent,
34+
ColumnPinningWithTemplateTestComponent
35+
]
36+
}).compileComponents();
3937
}));
4038

4139
describe('Base', () => {

projects/igniteui-angular/src/lib/grids/grid/column-resizing.spec.ts

+20-27
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,35 @@ import { Component, DebugElement, OnInit, ViewChild } from '@angular/core';
22
import { TestBed, fakeAsync, tick, ComponentFixture } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5-
import { IgxAvatarModule } from '../../avatar/avatar.component';
65
import { Calendar } from '../../calendar/public_api';
76
import { IgxGridComponent } from './grid.component';
8-
import { IgxGridModule, IColumnResizeEventArgs } from './public_api';
7+
import { IColumnResizeEventArgs, IgxColumnComponent } from './public_api';
98
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
109
import { GridTemplateStrings, ColumnDefinitions } from '../../test-utils/template-strings.spec';
1110
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
1211
import { MultiColumnHeadersComponent } from '../../test-utils/grid-samples.spec';
1312
import { configureTestSuite } from '../../test-utils/configure-suite';
1413
import { GridFunctions } from '../../test-utils/grid-functions.spec';
14+
import { IgxCellTemplateDirective } from '../columns/templates.directive';
15+
import { NgFor } from '@angular/common';
1516

1617
describe('IgxGrid - Deferred Column Resizing #grid', () => {
1718

1819
const COLUMN_HEADER_GROUP_CLASS = '.igx-grid-thead__item';
1920

2021
configureTestSuite((() => {
2122
return TestBed.configureTestingModule({
22-
declarations: [MultiColumnHeadersComponent],
23-
imports: [
24-
IgxAvatarModule,
25-
NoopAnimationsModule,
26-
IgxGridModule,
27-
ResizableColumnsComponent,
28-
GridFeaturesComponent,
29-
LargePinnedColGridComponent,
30-
NullColumnsComponent,
31-
ColGridComponent,
32-
ColPercentageGridComponent
33-
]
34-
});
23+
imports: [
24+
MultiColumnHeadersComponent,
25+
NoopAnimationsModule,
26+
ResizableColumnsComponent,
27+
GridFeaturesComponent,
28+
LargePinnedColGridComponent,
29+
NullColumnsComponent,
30+
ColGridComponent,
31+
ColPercentageGridComponent
32+
]
33+
});
3534
}));
3635

3736
describe('Base tests: ', () => {
@@ -870,8 +869,7 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
870869
@Component({
871870
template: GridTemplateStrings.declareGrid(`width="500px" height="300px"`, ``, ColumnDefinitions.resizableThreeOfFour),
872871
standalone: true,
873-
imports: [IgxAvatarModule,
874-
IgxGridModule]
872+
imports: [IgxGridComponent, IgxColumnComponent]
875873
})
876874
export class ResizableColumnsComponent {
877875
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;
@@ -894,8 +892,7 @@ export class ResizableColumnsComponent {
894892
<igx-column [field]="'Downloads'" width="100px" dataType="number" [resizable]="true"></igx-column>
895893
<igx-column [field]="'Category'" width="100px" dataType="string" [resizable]="true"></igx-column>`),
896894
standalone: true,
897-
imports: [IgxAvatarModule,
898-
IgxGridModule]
895+
imports: [IgxGridComponent, IgxColumnComponent, IgxCellTemplateDirective]
899896
})
900897
export class LargePinnedColGridComponent implements OnInit {
901898
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;
@@ -917,8 +914,7 @@ export class LargePinnedColGridComponent implements OnInit {
917914
@Component({
918915
template: GridTemplateStrings.declareGrid(``, ``, ColumnDefinitions.gridFeatures),
919916
standalone: true,
920-
imports: [IgxAvatarModule,
921-
IgxGridModule]
917+
imports: [IgxGridComponent, IgxColumnComponent, IgxCellTemplateDirective]
922918
})
923919
export class GridFeaturesComponent {
924920
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;
@@ -932,8 +928,7 @@ export class GridFeaturesComponent {
932928
@Component({
933929
template: GridTemplateStrings.declareGrid(`height="800px"`, ``, ColumnDefinitions.resizableColsComponent),
934930
standalone: true,
935-
imports: [IgxAvatarModule,
936-
IgxGridModule]
931+
imports: [IgxGridComponent, IgxColumnComponent, NgFor]
937932
})
938933
export class NullColumnsComponent implements OnInit {
939934
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;
@@ -967,8 +962,7 @@ export class NullColumnsComponent implements OnInit {
967962
<igx-column [field]="'Downloads'" width="300px" dataType="number" [resizable]="true"></igx-column>
968963
<igx-column [field]="'Category'" width="300px" dataType="string" [resizable]="true"></igx-column>`),
969964
standalone: true,
970-
imports: [IgxAvatarModule,
971-
IgxGridModule]
965+
imports: [IgxGridComponent, IgxColumnComponent]
972966
})
973967
export class ColGridComponent implements OnInit {
974968
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;
@@ -986,8 +980,7 @@ export class ColGridComponent implements OnInit {
986980
<igx-column [field]="'ProductName'" [width]="'25%'" dataType="string" [filterable]="true"></igx-column>
987981
<igx-column [field]="'Test'"[width]="'25%'" dataType="string" [resizable]="true"></igx-column>`),
988982
standalone: true,
989-
imports: [IgxAvatarModule,
990-
IgxGridModule]
983+
imports: [IgxGridComponent, IgxColumnComponent]
991984
})
992985
export class ColPercentageGridComponent implements OnInit {
993986
@ViewChild(IgxGridComponent, { static: true }) public grid: IgxGridComponent;

projects/igniteui-angular/src/lib/grids/grid/column-selection.spec.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
22
import { configureTestSuite } from '../../test-utils/configure-suite';
3-
import { IgxGridModule } from './grid.module';
43
import { IgxGridComponent } from './grid.component';
54
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
65
import { ProductsComponent, ColumnSelectionGroupTestComponent } from '../../test-utils/grid-samples.spec';
@@ -34,10 +33,8 @@ describe('IgxGrid - Column Selection #grid', () => {
3433

3534
configureTestSuite((() => {
3635
return TestBed.configureTestingModule({
37-
declarations: [ProductsComponent,
38-
ColumnSelectionGroupTestComponent],
39-
imports: [IgxGridModule, NoopAnimationsModule]
40-
});
36+
imports: [ProductsComponent, ColumnSelectionGroupTestComponent, NoopAnimationsModule]
37+
});
4138
}));
4239

4340
describe('Base tests: ', () => {

0 commit comments

Comments
 (0)