diff --git a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-search.spec.ts b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-search.spec.ts index c0dd0961d6d..7c8f6f65206 100644 --- a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-search.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-search.spec.ts @@ -5,11 +5,16 @@ import { TreeGridFunctions } from '../../test-utils/tree-grid-functions.spec'; import { IgxTreeGridSearchComponent, IgxTreeGridPrimaryForeignKeyComponent } from '../../test-utils/tree-grid-components.spec'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { configureTestSuite } from '../../test-utils/configure-suite'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; +const HIGHLIGHT_CLASS = 'igx-highlight'; +const ACTIVE_CLASS = 'igx-highlight__active'; describe('IgxTreeGrid - search API', () => { configureTestSuite(); let fix; + let fixNativeElement; let treeGrid: IgxTreeGridComponent; beforeEach(async(() => { @@ -26,7 +31,19 @@ describe('IgxTreeGrid - search API', () => { beforeEach(() => { fix = TestBed.createComponent(IgxTreeGridSearchComponent); fix.detectChanges(); + fixNativeElement = fix.debugElement.nativeElement; treeGrid = fix.componentInstance.treeGrid; + + treeGrid.getColumnByName('JobTitle').autosize(); + }); + + it('Search highlights should work for tree cells', () => { + const searchCount = treeGrid.findNext('QA'); + + const spans = getHighlightSpans(fixNativeElement); + const activeSpan = getActiveSpan(fixNativeElement); + + // TODO }); }); @@ -40,3 +57,11 @@ describe('IgxTreeGrid - search API', () => { }); }); + +function getHighlightSpans(parent: HTMLElement) { + return parent.querySelectorAll('.' + HIGHLIGHT_CLASS); +} + +function getActiveSpan(parent: HTMLElement) { + return parent.querySelector('.' + ACTIVE_CLASS); +} diff --git a/projects/igniteui-angular/src/lib/test-utils/tree-grid-functions.spec.ts b/projects/igniteui-angular/src/lib/test-utils/tree-grid-functions.spec.ts index 981efaf4f83..1d2ba3a4f1f 100644 --- a/projects/igniteui-angular/src/lib/test-utils/tree-grid-functions.spec.ts +++ b/projects/igniteui-angular/src/lib/test-utils/tree-grid-functions.spec.ts @@ -30,6 +30,12 @@ export class TreeGridFunctions { return rowDOM.query(By.css('igx-tree-grid-cell')); } + public static getCell(fix, rowIndex, columnKey) { + const rowDOM = TreeGridFunctions.sortElementsVertically(TreeGridFunctions.getAllRows(fix))[rowIndex]; + const rowCells = [TreeGridFunctions.getTreeCell(rowDOM)].concat(TreeGridFunctions.getNormalCells(rowDOM)); + return rowCells.filter((DOMcell) => DOMcell.componentInstance.column.field === columnKey)[0]; + } + public static getTreeCells(fix) { return fix.debugElement.queryAll(By.css('igx-tree-grid-cell')); }