@@ -557,12 +557,21 @@ describe('IgxGrid - Cell Editing #grid', () => {
557
557
it ( `Should properly emit 'onCellEditEnter' event` , ( ) => {
558
558
spyOn ( grid . onCellEditEnter , 'emit' ) . and . callThrough ( ) ;
559
559
let cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
560
+ let initialRowData = { ...cell . rowData } ;
560
561
expect ( cell . editMode ) . toBeFalsy ( ) ;
561
562
562
563
UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
563
564
fixture . detectChanges ( ) ;
564
565
565
- let cellArgs : IGridEditEventArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 'John Brown' , cancel : false } ;
566
+ let cellArgs : IGridEditEventArgs = {
567
+ rowID : cell . row . rowID ,
568
+ cellID : cell . cellID ,
569
+ rowData : initialRowData ,
570
+ oldValue : 'John Brown' ,
571
+ cancel : false ,
572
+ column : cell . column ,
573
+ owner : grid
574
+ } ;
566
575
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledTimes ( 1 ) ;
567
576
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
568
577
expect ( cell . editMode ) . toBeTruthy ( ) ;
@@ -573,7 +582,16 @@ describe('IgxGrid - Cell Editing #grid', () => {
573
582
574
583
expect ( cell . editMode ) . toBeFalsy ( ) ;
575
584
cell = grid . getCellByColumn ( 0 , 'age' ) ;
576
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 20 , cancel : false } ;
585
+ initialRowData = { ...cell . rowData } ;
586
+ cellArgs = {
587
+ cellID : cell . cellID ,
588
+ rowID : cell . row . rowID ,
589
+ rowData : initialRowData ,
590
+ oldValue : 20 ,
591
+ cancel : false ,
592
+ column : cell . column ,
593
+ owner : grid
594
+ } ;
577
595
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledTimes ( 2 ) ;
578
596
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
579
597
expect ( cell . editMode ) . toBeTruthy ( ) ;
@@ -585,25 +603,43 @@ describe('IgxGrid - Cell Editing #grid', () => {
585
603
e . cancel = true ;
586
604
} ) ;
587
605
let cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
606
+ let initialRowData = { ...cell . rowData } ;
588
607
expect ( cell . editMode ) . toBeFalsy ( ) ;
589
608
590
609
UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
591
610
fixture . detectChanges ( ) ;
592
611
593
- let cellArgs : IGridEditEventArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 'John Brown' , cancel : true } ;
612
+ let cellArgs : IGridEditEventArgs = {
613
+ cellID : cell . cellID ,
614
+ rowID : cell . row . rowID ,
615
+ rowData : initialRowData ,
616
+ oldValue : 'John Brown' ,
617
+ cancel : true ,
618
+ column : cell . column ,
619
+ owner : grid
620
+ } ;
594
621
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledTimes ( 1 ) ;
595
622
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
596
623
expect ( cell . editMode ) . toBeFalsy ( ) ;
597
624
598
625
// press enter on a cell
599
626
cell = grid . getCellByColumn ( 0 , 'age' ) ;
627
+ initialRowData = { ...cell . rowData } ;
600
628
UIInteractions . simulateClickAndSelectEvent ( cell ) ;
601
629
fixture . detectChanges ( ) ;
602
630
603
631
UIInteractions . triggerEventHandlerKeyDown ( 'enter' , gridContent ) ;
604
632
fixture . detectChanges ( ) ;
605
633
606
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 20 , cancel : true } ;
634
+ cellArgs = {
635
+ cellID : cell . cellID ,
636
+ rowID : cell . row . rowID ,
637
+ rowData : initialRowData ,
638
+ oldValue : 20 ,
639
+ cancel : true ,
640
+ column : cell . column ,
641
+ owner : grid
642
+ } ;
607
643
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledTimes ( 2 ) ;
608
644
expect ( grid . onCellEditEnter . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
609
645
expect ( cell . editMode ) . toBeFalsy ( ) ;
@@ -626,7 +662,17 @@ describe('IgxGrid - Cell Editing #grid', () => {
626
662
UIInteractions . triggerEventHandlerKeyDown ( 'tab' , gridContent ) ;
627
663
fixture . detectChanges ( ) ;
628
664
629
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 'John Brown' , newValue : 'New Name' , cancel : false } ;
665
+ // TODO: onCellEdit should emit updated rowData - issue #7304
666
+ cellArgs = {
667
+ cellID : cell . cellID ,
668
+ rowID : cell . row . rowID ,
669
+ rowData : cell . rowData ,
670
+ oldValue : 'John Brown' ,
671
+ newValue : 'New Name' ,
672
+ cancel : false ,
673
+ column : cell . column ,
674
+ owner : grid
675
+ } ;
630
676
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledTimes ( 1 ) ;
631
677
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
632
678
@@ -640,7 +686,17 @@ describe('IgxGrid - Cell Editing #grid', () => {
640
686
UIInteractions . triggerEventHandlerKeyDown ( 'enter' , gridContent ) ;
641
687
fixture . detectChanges ( ) ;
642
688
643
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 20 , newValue : 1 , cancel : false } ;
689
+ // TODO: onCellEdit should emit updated rowData - issue #7304
690
+ cellArgs = {
691
+ cellID : cell . cellID ,
692
+ rowID : cell . row . rowID ,
693
+ rowData : cell . rowData ,
694
+ oldValue : 20 ,
695
+ newValue : 1 ,
696
+ cancel : false ,
697
+ column : cell . column ,
698
+ owner : grid
699
+ } ;
644
700
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledTimes ( 2 ) ;
645
701
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
646
702
} ) ;
@@ -652,6 +708,7 @@ describe('IgxGrid - Cell Editing #grid', () => {
652
708
} ) ;
653
709
let cellArgs : IGridEditEventArgs ;
654
710
let cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
711
+ let initialRowData = { ...cell . rowData } ;
655
712
656
713
UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
657
714
fixture . detectChanges ( ) ;
@@ -665,14 +722,25 @@ describe('IgxGrid - Cell Editing #grid', () => {
665
722
UIInteractions . triggerEventHandlerKeyDown ( 'tab' , gridContent ) ;
666
723
fixture . detectChanges ( ) ;
667
724
668
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 'John Brown' , newValue : 'New Name' , cancel : true } ;
725
+ // TODO: onCellEdit should emit updated rowData - issue #7304
726
+ cellArgs = {
727
+ cellID : cell . cellID ,
728
+ rowID : cell . row . rowID ,
729
+ rowData : initialRowData ,
730
+ oldValue : 'John Brown' ,
731
+ newValue : 'New Name' ,
732
+ cancel : true ,
733
+ column : cell . column ,
734
+ owner : grid
735
+ } ;
669
736
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledTimes ( 1 ) ;
670
737
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
671
738
672
739
expect ( cell . editMode ) . toBe ( false ) ;
673
740
expect ( cell . value ) . toBe ( 'John Brown' ) ;
674
741
675
742
cell = grid . getCellByColumn ( 0 , 'age' ) ;
743
+ initialRowData = { ...cell . rowData } ;
676
744
expect ( cell . editMode ) . toBe ( true ) ;
677
745
editTemplate = fixture . debugElement . query ( By . css ( 'input' ) ) ;
678
746
UIInteractions . clickAndSendInputElementValue ( editTemplate , 1 ) ;
@@ -682,7 +750,17 @@ describe('IgxGrid - Cell Editing #grid', () => {
682
750
UIInteractions . triggerEventHandlerKeyDown ( 'enter' , gridContent ) ;
683
751
fixture . detectChanges ( ) ;
684
752
685
- cellArgs = { cellID : cell . cellID , rowID : cell . row . rowID , oldValue : 20 , newValue : '1' , cancel : true } ;
753
+ // TODO: onCellEdit should emit updated rowData - issue #7304
754
+ cellArgs = {
755
+ cellID : cell . cellID ,
756
+ rowID : cell . row . rowID ,
757
+ rowData : initialRowData ,
758
+ oldValue : 20 ,
759
+ newValue : '1' ,
760
+ cancel : true ,
761
+ column : cell . column ,
762
+ owner : grid
763
+ } ;
686
764
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledTimes ( 2 ) ;
687
765
expect ( grid . onCellEdit . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
688
766
@@ -767,6 +845,7 @@ describe('IgxGrid - Cell Editing #grid', () => {
767
845
it ( `Should properly emit 'onCellEditCancel' event` , ( ) => {
768
846
spyOn ( grid . onCellEditCancel , 'emit' ) . and . callThrough ( ) ;
769
847
const cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
848
+ const initialRowData = { ...cell . rowData } ;
770
849
771
850
UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
772
851
fixture . detectChanges ( ) ;
@@ -782,7 +861,13 @@ describe('IgxGrid - Cell Editing #grid', () => {
782
861
783
862
const cellArgs : IGridEditEventArgs = {
784
863
cellID : cell . cellID ,
785
- rowID : cell . row . rowID , oldValue : 'John Brown' , newValue : 'New Name' , cancel : false
864
+ rowID : cell . row . rowID ,
865
+ rowData : initialRowData ,
866
+ oldValue : 'John Brown' ,
867
+ newValue : 'New Name' ,
868
+ cancel : false ,
869
+ column : cell . column ,
870
+ owner : grid
786
871
} ;
787
872
expect ( grid . onCellEditCancel . emit ) . toHaveBeenCalledTimes ( 1 ) ;
788
873
expect ( grid . onCellEditCancel . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
@@ -796,6 +881,7 @@ describe('IgxGrid - Cell Editing #grid', () => {
796
881
e . cancel = true ;
797
882
} ) ;
798
883
const cell = grid . getCellByColumn ( 0 , 'fullName' ) ;
884
+ const initialRowData = { ...cell . rowData } ;
799
885
800
886
UIInteractions . simulateDoubleClickAndSelectEvent ( cell ) ;
801
887
fixture . detectChanges ( ) ;
@@ -805,13 +891,19 @@ describe('IgxGrid - Cell Editing #grid', () => {
805
891
UIInteractions . clickAndSendInputElementValue ( editTemplate , 'New Name' ) ;
806
892
fixture . detectChanges ( ) ;
807
893
808
- // press escape on edited cell
809
- UIInteractions . triggerEventHandlerKeyDown ( 'escape' , gridContent ) ;
810
- fixture . detectChanges ( ) ;
894
+ // press escape on edited cell
895
+ UIInteractions . triggerEventHandlerKeyDown ( 'escape' , gridContent ) ;
896
+ fixture . detectChanges ( ) ;
811
897
812
898
const cellArgs : IGridEditEventArgs = {
813
899
cellID : cell . cellID ,
814
- rowID : cell . row . rowID , oldValue : 'John Brown' , newValue : 'New Name' , cancel : true
900
+ rowID : cell . row . rowID ,
901
+ rowData : initialRowData ,
902
+ oldValue : 'John Brown' ,
903
+ newValue : 'New Name' ,
904
+ cancel : true ,
905
+ column : cell . column ,
906
+ owner : grid
815
907
} ;
816
908
expect ( grid . onCellEditCancel . emit ) . toHaveBeenCalledTimes ( 1 ) ;
817
909
expect ( grid . onCellEditCancel . emit ) . toHaveBeenCalledWith ( cellArgs ) ;
0 commit comments