@@ -3,7 +3,7 @@ import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
33import { By } from '@angular/platform-browser' ;
44import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
55import { IgxGridComponent } from './grid.component' ;
6- import { IGridEditDoneEventArgs , IGridEditEventArgs } from '../common/events' ;
6+ import { IGridEditDoneEventArgs , IGridEditEventArgs , IRowDataCancelableEventArgs } from '../common/events' ;
77import { IgxColumnComponent } from '../columns/column.component' ;
88import { DisplayDensity } from '../../core/density' ;
99import { UIInteractions , wait } from '../../test-utils/ui-interactions.spec' ;
@@ -299,6 +299,46 @@ describe('IgxGrid - Row Editing #grid', () => {
299299 expect ( grid . rowEditDone . emit ) . toHaveBeenCalledWith ( rowDoneArgs ) ;
300300 } ) ;
301301
302+ it ( 'Emit rowAdd event with proper arguments' , ( ) => {
303+ spyOn ( grid . rowAdd , 'emit' ) . and . callThrough ( ) ;
304+ // start add row
305+ grid . beginAddRowById ( null ) ;
306+ fix . detectChanges ( ) ;
307+
308+ const generatedId = grid . getRowByIndex ( 0 ) . cells [ 0 ] . value ;
309+
310+ // enter edit mode of cell
311+ const prodCell = GridFunctions . getRowCells ( fix , 0 ) [ 2 ] ;
312+ UIInteractions . simulateDoubleClickAndSelectEvent ( prodCell ) ;
313+ fix . detectChanges ( ) ;
314+
315+ // input value
316+ const cellInput = ( prodCell as any ) . nativeElement . querySelector ( '[igxinput]' ) ;
317+ UIInteractions . setInputElementValue ( cellInput , "NewValue" ) ;
318+ fix . detectChanges ( ) ;
319+
320+ // Done button click
321+ const doneButtonElement = GridFunctions . getRowEditingDoneButton ( fix ) ;
322+ doneButtonElement . click ( ) ;
323+ fix . detectChanges ( ) ;
324+
325+ // check event args
326+ const rowAddArgs : IRowDataCancelableEventArgs = {
327+ cancel : false ,
328+ oldValue : { ProductID : generatedId } ,
329+ rowData : { ProductID : generatedId , ProductName : "NewValue" } ,
330+ data : { ProductID : generatedId , ProductName : "NewValue" } ,
331+ rowID : generatedId ,
332+ primaryKey : generatedId ,
333+ rowKey : generatedId ,
334+ valid : true ,
335+ event : jasmine . anything ( ) as any ,
336+ owner : grid ,
337+ isAddRow : true
338+ }
339+ expect ( grid . rowAdd . emit ) . toHaveBeenCalledWith ( rowAddArgs ) ;
340+ } ) ;
341+
302342 it ( 'Should display the banner below the edited row if it is not the last one' , ( ) => {
303343 cell . editMode = true ;
304344
0 commit comments