Skip to content

Commit

Permalink
fix(IgxGrid): Fix event args for rowAdded too. Update test. (#14121)
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaKirova authored May 13, 2024
1 parent fa71ff4 commit 8bed1a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class IgxAddRow extends IgxEditRow {
const args = super.createRowEditEventArgs(includeNewValue, event);
args.oldValue = null;
args.isAddRow = true;
args.rowData = this.newData ?? this.data;
return args;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { IgxGridComponent } from './grid.component';
import { IGridEditDoneEventArgs, IGridEditEventArgs, IRowDataCancelableEventArgs } from '../common/events';
import { IGridEditDoneEventArgs, IGridEditEventArgs, IRowDataCancelableEventArgs, IRowDataEventArgs } from '../common/events';
import { IgxColumnComponent } from '../columns/column.component';
import { DisplayDensity } from '../../core/density';
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
Expand Down Expand Up @@ -299,8 +299,9 @@ describe('IgxGrid - Row Editing #grid', () => {
expect(grid.rowEditDone.emit).toHaveBeenCalledWith(rowDoneArgs);
});

it('Emit rowAdd event with proper arguments', () => {
it('Emit rowAdd and rowAdded event with proper arguments', () => {
spyOn(grid.rowAdd, 'emit').and.callThrough();
spyOn(grid.rowAdded, 'emit').and.callThrough();
// start add row
grid.beginAddRowById(null);
fix.detectChanges();
Expand Down Expand Up @@ -336,7 +337,16 @@ describe('IgxGrid - Row Editing #grid', () => {
owner: grid,
isAddRow: true
}

const rowAddedArgs: IRowDataEventArgs = {
rowData: { ProductID: generatedId, ProductName: "NewValue"},
data: { ProductID: generatedId, ProductName: "NewValue"},
primaryKey: generatedId,
rowKey: generatedId,
owner: grid
};
expect(grid.rowAdd.emit).toHaveBeenCalledWith(rowAddArgs);
expect(grid.rowAdded.emit).toHaveBeenCalledWith(rowAddedArgs);
});

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

0 comments on commit 8bed1a9

Please sign in to comment.