Skip to content

Commit 1b2c601

Browse files
committed
test(igx-grid): add more tests #2530
1 parent 85e1b9e commit 1b2c601

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,6 @@ describe('igxCombo', () => {
30263026
tick();
30273027
fixture.detectChanges();
30283028
// tslint:disable-next-line:no-debugger
3029-
debugger;
30303029
expect(combo.selectedItems()).toEqual(fixture.componentInstance.comboSelectedItems);
30313030
combo.selectItems([...data].splice(1, 3), true);
30323031
fixture.detectChanges();

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

+26-5
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ describe('IgxGrid Component Tests', () => {
986986
const row = grid.getRowByIndex(0);
987987
const cell = grid.getCellByColumn(0, 'ProductName');
988988
const cellDom = cell.nativeElement;
989+
let cellInput = null;
989990

990991
cellDom.dispatchEvent(new Event('focus'));
991992
fix.detectChanges();
@@ -994,18 +995,38 @@ describe('IgxGrid Component Tests', () => {
994995
cellDom.dispatchEvent(new Event('dblclick'));
995996
expect(row.inEditMode).toBe(true);
996997

997-
let cellArgs: IGridEditEventArgs = { row: cell.row, cell: cell, oldValue: cell.value, cancel: false };
998-
let rowArgs: IGridEditEventArgs = { row: row, cell: cell, oldValue: row.rowData, cancel: false };
998+
let cellArgs: IGridEditEventArgs = { cellID: cell.cellID, rowID: cell.row.rowID, oldValue: cell.value, cancel: false };
999+
let rowArgs: IGridEditEventArgs = { rowID: row.rowID, oldValue: row.rowData, cancel: false };
9991000
expect(grid.onCellEnterEditMode.emit).toHaveBeenCalledWith(cellArgs);
10001001
expect(grid.onRowEnterEditMode.emit).toHaveBeenCalledWith(rowArgs);
10011002

10021003
UIInteractions.triggerKeyDownEvtUponElem('escape', cellDom, true);
10031004
tick();
10041005

1005-
cellArgs = { cell: cell, row: cell.row, oldValue: cell.value, newValue: cell.value, cancel: false };
1006-
rowArgs = { row: null, cell: null, oldValue: row.rowData, newValue: row.rowData, cancel: false };
1006+
expect(row.inEditMode).toBe(false);
1007+
cellArgs = { cellID: cell.cellID, rowID: cell.row.rowID, oldValue: cell.value, newValue: cell.value, cancel: false };
1008+
rowArgs = { rowID: row.rowID, oldValue: row.rowData, newValue: row.rowData, cancel: false };
1009+
expect(grid.onCellEditCancel.emit).toHaveBeenCalledWith(cellArgs);
1010+
expect(grid.onRowEditCancel.emit).toHaveBeenCalledWith(rowArgs);
1011+
1012+
cellDom.dispatchEvent(new Event('dblclick'));
1013+
tick();
1014+
expect(row.inEditMode).toBe(true);
1015+
1016+
const newCellValue = 'Aaaaa';
1017+
cellInput = cellDom.querySelector('[igxinput]');
1018+
cellInput.value = newCellValue;
1019+
cellInput.dispatchEvent(new Event('input'));
1020+
tick();
1021+
1022+
UIInteractions.triggerKeyDownEvtUponElem('enter', cellDom, true);
1023+
tick();
1024+
1025+
const newRowValue = grid.transactions().getAggregatedValue(row.rowID, true);
1026+
cellArgs = { cellID: cell.cellID, rowID: cell.row.rowID, oldValue: cell.value, newValue: newCellValue, cancel: false };
1027+
rowArgs = { rowID: row.rowID, oldValue: row.rowData, newValue: newRowValue, cancel: false };
10071028
expect(grid.onCellEditCancel.emit).toHaveBeenCalledWith(cellArgs);
1008-
// expect(grid.onRowEditCancel.emit).toHaveBeenCalledWith(rowArgs);
1029+
expect(grid.onRowEditCancel.emit).toHaveBeenCalledWith(rowArgs);
10091030
}));
10101031

10111032
it('Should display the banner below the edited row if it is not the last one', fakeAsync(() => {

0 commit comments

Comments
 (0)