@@ -155,28 +155,51 @@ describe('Row Pinning #grid', () => {
155
155
let row = grid . getRowByIndex ( 0 ) ;
156
156
const rowID = row . key ;
157
157
row . pin ( ) ;
158
- fix . detectChanges ( ) ;
159
158
160
159
// Check pinned state with getRowByIndex after pin action
161
160
expect ( row . pinned ) . toBe ( true ) ;
162
161
163
162
expect ( grid . rowPinning . emit ) . toHaveBeenCalledTimes ( 1 ) ;
164
163
expect ( grid . rowPinning . emit ) . toHaveBeenCalledWith ( {
165
164
rowID,
166
- insertAtIndex : undefined ,
165
+ insertAtIndex : 0 ,
167
166
isPinned : true ,
168
167
row
169
168
} ) ;
170
169
171
170
row = grid . getRowByIndex ( 0 ) ;
172
171
row . unpin ( ) ;
173
- fix . detectChanges ( ) ;
174
172
// Check pinned state with getRowByIndex after unpin action
175
173
expect ( row . pinned ) . toBe ( false ) ;
176
174
177
175
expect ( grid . rowPinning . emit ) . toHaveBeenCalledTimes ( 2 ) ;
178
176
} ) ;
179
177
178
+ it ( 'should emit rowPinned on pin/unpin.' , ( ) => {
179
+ spyOn ( grid . rowPinned , 'emit' ) . and . callThrough ( ) ;
180
+
181
+ const row = grid . getRowByIndex ( 0 ) ;
182
+ const rowID = row . key ;
183
+ row . pin ( ) ;
184
+
185
+ // Check pinned state with getRowByIndex after pin action
186
+ expect ( row . pinned ) . toBe ( true ) ;
187
+
188
+ expect ( grid . rowPinned . emit ) . toHaveBeenCalledTimes ( 1 ) ;
189
+ expect ( grid . rowPinned . emit ) . toHaveBeenCalledWith ( {
190
+ rowID,
191
+ insertAtIndex : 0 ,
192
+ isPinned : true ,
193
+ row
194
+ } ) ;
195
+
196
+ row . unpin ( ) ;
197
+ // Check pinned state with getRowByIndex after unpin action
198
+ expect ( row . pinned ) . toBe ( false ) ;
199
+
200
+ expect ( grid . rowPinned . emit ) . toHaveBeenCalledTimes ( 2 ) ;
201
+ } ) ;
202
+
180
203
it ( 'should pin/unpin via grid API methods.' , ( ) => {
181
204
// pin 2nd row
182
205
grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
@@ -223,7 +246,6 @@ describe('Row Pinning #grid', () => {
223
246
// unpin
224
247
row = grid . gridAPI . get_row_by_index ( 0 ) ;
225
248
row . unpin ( ) ;
226
- fix . detectChanges ( ) ;
227
249
228
250
expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
229
251
pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
@@ -429,8 +451,7 @@ describe('Row Pinning #grid', () => {
429
451
430
452
it ( 'should apply sorting to both pinned and unpinned rows.' , ( ) => {
431
453
grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
432
- grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
433
- fix . detectChanges ( ) ;
454
+ grid . gridAPI . get_row_by_index ( 6 ) . pin ( ) ;
434
455
435
456
expect ( grid . gridAPI . get_row_by_index ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
436
457
expect ( grid . gridAPI . get_row_by_index ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 5 ] ) ;
@@ -573,7 +594,6 @@ describe('Row Pinning #grid', () => {
573
594
it ( 'should correctly apply paging state for grid and paginator when there are pinned rows.' , ( ) => {
574
595
// pin the first row
575
596
grid . gridAPI . get_row_by_index ( 0 ) . pin ( ) ;
576
- fix . detectChanges ( ) ;
577
597
578
598
expect ( grid . rowList . length ) . toEqual ( 6 ) ;
579
599
expect ( grid . perPage ) . toEqual ( 5 ) ;
@@ -583,7 +603,6 @@ describe('Row Pinning #grid', () => {
583
603
584
604
// pin the second row
585
605
grid . gridAPI . get_row_by_index ( 2 ) . pin ( ) ;
586
- fix . detectChanges ( ) ;
587
606
588
607
expect ( grid . rowList . length ) . toEqual ( 7 ) ;
589
608
expect ( grid . perPage ) . toEqual ( 5 ) ;
@@ -594,19 +613,17 @@ describe('Row Pinning #grid', () => {
594
613
595
614
it ( 'should have the correct records shown for pages with pinned rows' , ( ) => {
596
615
grid . gridAPI . get_row_by_index ( 0 ) . pin ( ) ;
597
- grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
598
- fix . detectChanges ( ) ;
599
616
600
617
let rows = grid . rowList . toArray ( ) ;
601
618
602
- [ 1 , 2 , 1 , 2 , 3 , 4 , 5 ] . forEach ( ( x , index ) => expect ( rows [ index ] . cells . first . value ) . toEqual ( x ) ) ;
619
+ [ 1 , 1 , 2 , 3 , 4 , 5 ] . forEach ( ( x , index ) => expect ( rows [ index ] . cells . first . value ) . toEqual ( x ) ) ;
603
620
604
621
grid . paginate ( 2 ) ;
605
622
fix . detectChanges ( ) ;
606
623
607
624
rows = grid . rowList . toArray ( ) ;
608
625
609
- [ 1 , 2 , 11 , 12 ] . forEach ( ( x , index ) => expect ( rows [ index ] . cells . first . value ) . toEqual ( x ) ) ;
626
+ [ 1 , 11 , 12 ] . forEach ( ( x , index ) => expect ( rows [ index ] . cells . first . value ) . toEqual ( x ) ) ;
610
627
} ) ;
611
628
} ) ;
612
629
@@ -805,10 +822,8 @@ describe('Row Pinning #grid', () => {
805
822
// Pin/Unpin with the methods
806
823
firstRow . unpin ( ) ;
807
824
expect ( firstRow . pinned ) . toBe ( false ) ;
808
- fix . detectChanges ( ) ;
809
825
firstRow . pin ( ) ;
810
826
expect ( firstRow . pinned ) . toBe ( true ) ;
811
- fix . detectChanges ( ) ;
812
827
813
828
// Check again pinned row presence
814
829
pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
@@ -855,7 +870,6 @@ describe('Row Pinning #grid', () => {
855
870
it ( 'should hide columns in pinned and unpinned area' , ( ) => {
856
871
// pin 2nd data row
857
872
grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
858
- fix . detectChanges ( ) ;
859
873
const hiddenCol = grid . columns [ 1 ] ;
860
874
hiddenCol . hidden = true ;
861
875
fix . detectChanges ( ) ;
@@ -892,14 +906,9 @@ describe('Row Pinning #grid', () => {
892
906
893
907
it ( 'should keep the scrollbar sizes correct when partially filtering out pinned records' , ( ) => {
894
908
grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
895
- fix . detectChanges ( ) ;
896
909
grid . gridAPI . get_row_by_index ( 3 ) . pin ( ) ;
897
- fix . detectChanges ( ) ;
898
910
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
899
- fix . detectChanges ( ) ;
900
911
grid . gridAPI . get_row_by_index ( 7 ) . pin ( ) ;
901
- fix . detectChanges ( ) ;
902
-
903
912
fix . detectChanges ( ) ;
904
913
// 4 records pinned + 2px border
905
914
expect ( grid . pinnedRowHeight ) . toBe ( 4 * grid . renderedRowHeight + 2 ) ;
@@ -929,9 +938,7 @@ describe('Row Pinning #grid', () => {
929
938
it ( 'should enter edit mode for the next editable cell when tabbing.' , ( ) => {
930
939
const gridContent = GridFunctions . getGridContent ( fix ) ;
931
940
grid . gridAPI . get_row_by_index ( 0 ) . pin ( ) ;
932
- fix . detectChanges ( ) ;
933
941
grid . gridAPI . get_row_by_index ( 3 ) . pin ( ) ;
934
- fix . detectChanges ( ) ;
935
942
936
943
const firstEditable = grid . gridAPI . get_cell_by_index ( 0 , 'CompanyName' ) ;
937
944
const secondEditable = grid . gridAPI . get_cell_by_index ( 1 , 'CompanyName' ) ;
@@ -967,9 +974,7 @@ describe('Row Pinning #grid', () => {
967
974
it ( 'should enter edit mode for the previous editable cell when shift+tabbing.' , ( ) => {
968
975
const gridContent = GridFunctions . getGridContent ( fix ) ;
969
976
grid . gridAPI . get_row_by_index ( 0 ) . pin ( ) ;
970
- fix . detectChanges ( ) ;
971
977
grid . gridAPI . get_row_by_index ( 3 ) . pin ( ) ;
972
- fix . detectChanges ( ) ;
973
978
974
979
const firstEditable = grid . gridAPI . get_cell_by_index ( 0 , 'CompanyName' ) ;
975
980
const secondEditable = grid . gridAPI . get_cell_by_index ( 1 , 'CompanyName' ) ;
@@ -1017,7 +1022,6 @@ describe('Row Pinning #grid', () => {
1017
1022
1018
1023
it ( 'should navigate to bottom from top pinned row using Ctrl+ArrowDown' , async ( ) => {
1019
1024
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1020
- fix . detectChanges ( ) ;
1021
1025
1022
1026
const firstRowCell = grid . gridAPI . get_row_by_index ( 0 ) . cells . toArray ( ) [ 1 ] ;
1023
1027
UIInteractions . simulateClickAndSelectEvent ( firstRowCell ) ;
@@ -1039,7 +1043,6 @@ describe('Row Pinning #grid', () => {
1039
1043
1040
1044
it ( 'should navigate and scroll to first unpinned row from top pinned row using ArrowDown' , async ( ) => {
1041
1045
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1042
- fix . detectChanges ( ) ;
1043
1046
1044
1047
grid . navigateTo ( 10 ) ;
1045
1048
await wait ( DEBOUNCE_TIME ) ;
@@ -1064,7 +1067,6 @@ describe('Row Pinning #grid', () => {
1064
1067
1065
1068
it ( 'should navigate to top pinned row from bottom unpinned row without scrolling using Ctrl+ArrowUp' , async ( ) => {
1066
1069
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1067
- fix . detectChanges ( ) ;
1068
1070
1069
1071
grid . navigateTo ( 27 ) ;
1070
1072
await wait ( DEBOUNCE_TIME ) ;
@@ -1095,7 +1097,6 @@ describe('Row Pinning #grid', () => {
1095
1097
it ( 'should navigate to top pinned row from first unpinned row using ArrowUp' , async ( ) => {
1096
1098
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1097
1099
grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
1098
- fix . detectChanges ( ) ;
1099
1100
1100
1101
const thirdRowCell = grid . gridAPI . get_row_by_index ( 2 ) . cells . toArray ( ) [ 1 ] ;
1101
1102
UIInteractions . simulateClickAndSelectEvent ( thirdRowCell ) ;
@@ -1118,7 +1119,6 @@ describe('Row Pinning #grid', () => {
1118
1119
it ( 'should navigate and scroll to top from bottom pinned row using Ctrl+ArrowUp' , async ( ) => {
1119
1120
fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
1120
1121
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1121
- fix . detectChanges ( ) ;
1122
1122
1123
1123
grid . navigateTo ( 26 ) ;
1124
1124
await wait ( DEBOUNCE_TIME ) ;
@@ -1171,7 +1171,6 @@ describe('Row Pinning #grid', () => {
1171
1171
it ( 'should navigate to bottom pinned row from top unpinned row without scrolling using Ctrl+ArrowDown' , async ( ) => {
1172
1172
fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
1173
1173
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1174
- fix . detectChanges ( ) ;
1175
1174
1176
1175
expect ( grid . verticalScrollContainer . getScroll ( ) . scrollTop ) . toEqual ( 0 ) ;
1177
1176
@@ -1199,7 +1198,6 @@ describe('Row Pinning #grid', () => {
1199
1198
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1200
1199
grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
1201
1200
await wait ( DEBOUNCE_TIME ) ;
1202
- fix . detectChanges ( ) ;
1203
1201
1204
1202
grid . navigateTo ( 26 ) ;
1205
1203
await wait ( DEBOUNCE_TIME ) ;
@@ -1228,8 +1226,6 @@ describe('Row Pinning #grid', () => {
1228
1226
it ( 'should navigate down from pinned to unpinned row when there are filtered out pinned rows' , async ( ) => {
1229
1227
grid . gridAPI . get_row_by_index ( 5 ) . pin ( ) ;
1230
1228
grid . gridAPI . get_row_by_index ( 1 ) . pin ( ) ;
1231
- fix . detectChanges ( ) ;
1232
-
1233
1229
grid . filter ( 'ID' , 'B' , IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) , false ) ;
1234
1230
fix . detectChanges ( ) ;
1235
1231
0 commit comments