|
1 |
| -import { TestBed, ComponentFixture, waitForAsync } from '@angular/core/testing'; |
| 1 | +import { TestBed, ComponentFixture, waitForAsync, fakeAsync, tick } from '@angular/core/testing'; |
2 | 2 | import { DebugElement } from '@angular/core';
|
3 | 3 | import { IgxTreeGridComponent } from './tree-grid.component';
|
4 | 4 | import { CellType, IgxTreeGridModule } from './public_api';
|
@@ -593,6 +593,30 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
|
593 | 593 | const editedParentCell = parentRow.cells.filter(c => c.column.field === 'Age')[0];
|
594 | 594 | expect(editedParentCell.value).toEqual(80);
|
595 | 595 | });
|
| 596 | + |
| 597 | + it('should select the text when the first cell (tree grid cell) enters edit mode', fakeAsync(() => { |
| 598 | + const grid = fix.componentInstance.treeGrid as IgxTreeGridComponent; |
| 599 | + grid.expandAll(); |
| 600 | + fix.detectChanges(); |
| 601 | + |
| 602 | + // move the 'string' column 'Name' to first position, so its cells are the tree grid cells |
| 603 | + const colName = grid.getColumnByName('Name'); |
| 604 | + const colHireDate = grid.getColumnByName('HireDate'); |
| 605 | + grid.moveColumn(colName, colHireDate, DropPosition.BeforeDropTarget); |
| 606 | + fix.detectChanges(); |
| 607 | + tick(100); |
| 608 | + |
| 609 | + const cell = grid.gridAPI.get_cell_by_index(0, 'Name'); |
| 610 | + cell.setEditMode(true); |
| 611 | + fix.detectChanges(); |
| 612 | + tick(100); |
| 613 | + |
| 614 | + expect(cell.editMode).toBe(true); |
| 615 | + expect(document.activeElement.nodeName).toEqual('INPUT') |
| 616 | + expect((document.activeElement as HTMLInputElement).value).toBe('John Winchester'); |
| 617 | + expect((document.activeElement as HTMLInputElement).selectionStart).toEqual(0); |
| 618 | + expect((document.activeElement as HTMLInputElement).selectionEnd).toEqual(15); |
| 619 | + })); |
596 | 620 | });
|
597 | 621 |
|
598 | 622 | describe('Batch Editing', () => {
|
|
0 commit comments