Skip to content

Commit a1fa847

Browse files
HristoP96HristoP96
authored andcommitted
chore(*): additional refactoring
1 parent 64e3652 commit a1fa847

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { async, TestBed, fakeAsync } from '@angular/core/testing';
2-
import { By } from '@angular/platform-browser';
32
import { SortingDirection } from '../../data-operations/sorting-expression.interface';
43
import { IgxGridComponent } from './grid.component';
54
import { IgxGridModule } from './index';
65
import { DefaultSortingStrategy, NoopSortingStrategy } from '../../data-operations/sorting-strategy';
76
import { IgxGridCellComponent } from '../cell.component';
87
import { configureTestSuite } from '../../test-utils/configure-suite';
9-
import { IgxGridFilteringRowComponent } from '../filtering/base/grid-filtering-row.component';
10-
import { IgxChipComponent } from '../../chips/chip.component';
118
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
129
import { GridFunctions } from '../../test-utils/grid-functions.spec';
1310
import { GridDeclaredColumnsComponent, SortByParityComponent } from '../../test-utils/grid-samples.spec';
14-
import { ControlsFunction } from '../../test-utils/controls-functions.spec';
1511
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
1612

1713
const SORTING_ICON_ASC_CONTENT = 'arrow_upward';
@@ -246,9 +242,8 @@ describe('IgxGrid - Grid Sorting #grid', () => {
246242
describe('UI tests', () => {
247243

248244
it('Should sort grid ascending by clicking once on first header cell UI', () => {
249-
const firstHeaderCell = GridFunctions.getColumnHeader('ID', fixture);
250245

251-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
246+
GridFunctions.clickColumnHeaderUI('ID', fixture);
252247
fixture.detectChanges();
253248

254249
const firstRowFirstCell = getCurrentCellFromGrid(grid, 0, 0);
@@ -263,11 +258,10 @@ describe('IgxGrid - Grid Sorting #grid', () => {
263258
});
264259

265260
it('Should sort grid descending by clicking twice on sort icon UI', () => {
266-
const firstHeaderCell = GridFunctions.getColumnHeader('ID', fixture);
267261

268-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
262+
GridFunctions.clickColumnHeaderUI('ID', fixture);
269263
fixture.detectChanges();
270-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
264+
GridFunctions.clickColumnHeaderUI('ID', fixture);
271265
fixture.detectChanges();
272266

273267
const firstRowFirstCell = getCurrentCellFromGrid(grid, 0, 0);
@@ -282,13 +276,12 @@ describe('IgxGrid - Grid Sorting #grid', () => {
282276
});
283277

284278
it('Should sort grid none when we click three time on header sort icon UI', () => {
285-
const firstHeaderCell = GridFunctions.getColumnHeader('ID', fixture);
286279

287-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
280+
GridFunctions.clickColumnHeaderUI('ID', fixture);
288281
fixture.detectChanges();
289-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
282+
GridFunctions.clickColumnHeaderUI('ID', fixture);
290283
fixture.detectChanges();
291-
GridFunctions.clickHeaderSortIcon(firstHeaderCell);
284+
GridFunctions.clickColumnHeaderUI('ID', fixture);
292285
fixture.detectChanges();
293286

294287
const firstRowSecondCell = getCurrentCellFromGrid(grid, 0, 1);

projects/igniteui-angular/src/lib/test-utils/grid-functions.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,13 @@ export class GridFunctions {
938938
fix.detectChanges();
939939
}
940940

941+
/**
942+
* returns the filter row debug element.
943+
*/
944+
public static getFilterRow(fix: ComponentFixture<any>): DebugElement {
945+
return fix.debugElement.query(By.css(FILTER_UI_ROW));
946+
}
947+
941948
/**
942949
* Click the filter chip for the provided column in order to open the filter row for it.
943950
*/
@@ -1052,6 +1059,12 @@ export class GridFunctions {
10521059
return sortedNativeHeaders[index].querySelector('.igx-grid__th-title');
10531060
}
10541061

1062+
public static clickColumnHeaderUI(columnField: string, fix: ComponentFixture<any>, ctrlKey = false, shiftKey = false) {
1063+
const header = this.getColumnHeader(columnField, fix);
1064+
header.triggerEventHandler('click', new MouseEvent('click', { shiftKey: shiftKey, ctrlKey: ctrlKey}));
1065+
fix.detectChanges();
1066+
}
1067+
10551068
public static getFilterChipsForColumn(columnField: string, fix: ComponentFixture<any>) {
10561069
const columnHeader = this.getColumnHeader(columnField, fix);
10571070
return columnHeader.parent.queryAll(By.directive(IgxChipComponent));

0 commit comments

Comments
 (0)