@@ -23,7 +23,7 @@ class TestComponent extends CollectionWidget {
2323 _itemClass ( ) { return 'item' ; }
2424 _itemDataKey ( ) { return '123' ; }
2525 _itemContainer ( ) { return this . $element ( ) ; }
26- _shouldAppendItems ( ) { return true ; }
26+ _allowDynamicItemsAppend ( ) { return true ; }
2727
2828 reload ( ) {
2929 super . reload ( ) ;
@@ -60,13 +60,16 @@ class LiveUpdateTestHelper {
6060
6161 return new TestComponent ( this . $element , options || {
6262 dataSource : new DataSource ( {
63- load : ( e ) => this . data . sort ( ( a , b ) => a . index - b . index ) ,
63+ load : ( ) => this . data . sort ( ( a , b ) => a . index - b . index ) ,
6464 loadMode : 'raw' ,
6565 pageSize : 2 ,
6666 pushAggregationTimeout : 0 ,
67- key : 'id'
67+ reshapeOnPush : true ,
68+ sort : { field : 'index' } ,
69+ key : 'id' ,
6870 } ) ,
69- onItemDeleting : this . onItemDeletingSpy
71+ repaintChangesOnly : true ,
72+ onItemDeleting : this . onItemDeletingSpy ,
7073 } ) ;
7174 }
7275
@@ -85,29 +88,29 @@ module('live update', {
8588} , ( ) => {
8689 test ( 'check load next page' , function ( assert ) {
8790 assert . equal ( helper . getItems ( ) . length , 2 ) ;
88- helper . instance . loadNextPage ( ) ;
91+ helper . instance . _loadNextPage ( ) ;
8992 assert . equal ( helper . getItems ( ) [ 2 ] , helper . data [ 2 ] ) ;
9093 assert . equal ( helper . getItems ( ) . length , 4 ) ;
9194 } ) ;
9295
9396 test ( 'correct index after push insert' , function ( assert ) {
9497 helper . store . push ( [ { type : 'insert' , data : { id : 200 , text : 'text ' + 200 , index : 0 } , index : 0 } ] ) ;
95- helper . instance . loadNextPage ( ) ;
96- assert . equal ( helper . getItems ( ) . length , 5 ) ;
98+ helper . instance . _loadNextPage ( ) ;
99+ assert . equal ( helper . getItems ( ) . length , 4 ) ;
97100 assert . equal ( helper . getItems ( ) [ 0 ] . id , 200 ) ;
98- assert . equal ( helper . getItems ( ) [ 4 ] . id , 4 ) ;
101+ assert . equal ( helper . getItems ( ) [ 3 ] . id , 2 ) ;
99102 } ) ;
100103
101- test ( 'correct index after push \' remove\' ' , function ( assert ) {
104+ test ( 'correct index after push remove' , function ( assert ) {
102105 helper . store . push ( [ { type : 'remove' , key : 0 } ] ) ;
103- helper . instance . loadNextPage ( ) ;
104- assert . equal ( helper . getItems ( ) . length , 3 ) ;
106+ helper . instance . _loadNextPage ( ) ;
107+ assert . equal ( helper . getItems ( ) . length , 4 ) ;
105108 assert . equal ( helper . getItems ( ) [ 0 ] . id , 1 ) ;
106- assert . equal ( helper . getItems ( ) [ 2 ] . id , 3 ) ;
109+ assert . equal ( helper . getItems ( ) [ 1 ] . id , 2 ) ;
107110 } ) ;
108111
109112 // T723520
110- test ( 'correct index after push \' remove\' and dataSource reload' , function ( assert ) {
113+ test ( 'correct index after push remove and dataSource reload' , function ( assert ) {
111114 helper . instance . _shouldAppendItems = ( ) => false ;
112115 helper . instance . getDataSource ( ) . pageSize ( 20 ) ;
113116 helper . instance . reload ( ) ;
@@ -125,13 +128,13 @@ module('live update', {
125128 assert . equal ( take , 20 ) ;
126129 } ) ;
127130
128- test ( 'fire deleting event after push \' remove\' ' , function ( assert ) {
131+ test ( 'fire deleting event after push remove' , function ( assert ) {
129132 assert . equal ( helper . onItemDeletingSpy . callCount , 0 ) ;
130133 helper . store . push ( [ { type : 'remove' , key : 0 } ] ) ;
131134 assert . equal ( helper . onItemDeletingSpy . callCount , 1 ) ;
132135 } ) ;
133136
134- test ( 'fire dxremove event after push \' remove\' ' , function ( assert ) {
137+ test ( 'fire dxremove event after push remove' , function ( assert ) {
135138 const removeSpy = sinon . spy ( ) ;
136139
137140 $ ( '.dx-item' ) . on ( 'dxremove' , removeSpy ) ;
@@ -142,15 +145,15 @@ module('live update', {
142145
143146 test ( 'refresh correct index after reload' , function ( assert ) {
144147 helper . store . push ( [ { type : 'insert' , data : { id : 200 , text : 'text ' + 200 , index : 0 } , index : 0 } ] ) ;
145- assert . equal ( helper . getItems ( ) . length , 3 ) ;
148+ assert . equal ( helper . getItems ( ) . length , 2 ) ;
146149 helper . instance . reload ( ) ;
147150 assert . equal ( helper . getItems ( ) [ 0 ] . id , 200 ) ;
148151 assert . equal ( helper . getItems ( ) [ 1 ] . id , 0 ) ;
149152 assert . equal ( helper . getItems ( ) . length , 2 ) ;
150153 assert . equal ( helper . instance . itemElements ( ) . length , 2 ) ;
151154 } ) ;
152155
153- test ( 'item is pushed to the end of store\'s array' , function ( assert ) {
156+ test ( 'item is pushed to the end of store array' , function ( assert ) {
154157 helper . store . push ( [ { type : 'insert' , data : { id : 200 , text : 'text ' + 200 , index : 0 } , index : 0 } ] ) ;
155158 assert . equal ( helper . data . pop ( ) . id , 200 ) ;
156159 } ) ;
@@ -168,7 +171,8 @@ module('live update', {
168171 helper . reinitializeWithOptions ( {
169172 dataSource : {
170173 store,
171- paginate : true
174+ paginate : true ,
175+ reshapeOnPush : true ,
172176 } ,
173177 displayExpr : 'text' ,
174178 repaintChangesOnly : true
@@ -190,6 +194,7 @@ module('live update', {
190194 loadMode : 'raw' ,
191195 pageSize : 2 ,
192196 pushAggregationTimeout : 0 ,
197+ reshapeOnPush : true ,
193198 key : 'id'
194199 } ) ;
195200 helper . instance . option ( 'dataSource' , newDataSource ) ;
@@ -202,27 +207,30 @@ module('live update', {
202207 newDataSource . store ( ) . push ( [ { type : 'remove' , key : 0 } ] ) ;
203208
204209 items = helper . getItems ( ) ;
205- assert . strictEqual ( items . length , 1 , '1 item on the first page after remove' ) ;
210+ assert . strictEqual ( items . length , 2 , '2 item on the first page after remove' ) ;
206211 assert . strictEqual ( items [ 0 ] . id , 1 , '1 item' ) ;
207212
208- helper . instance . loadNextPage ( ) ;
213+ helper . instance . _loadNextPage ( ) ;
209214
210215 items = helper . getItems ( ) ;
211- assert . strictEqual ( items . length , 3 , '2 pages are loaded' ) ;
216+ assert . strictEqual ( items . length , 4 , '2 pages are loaded' ) ;
212217 assert . strictEqual ( items [ 0 ] . id , 1 , '1 item' ) ;
213218 assert . strictEqual ( items [ 1 ] . id , 2 , '2 item' ) ;
214219 assert . strictEqual ( items [ 2 ] . id , 3 , '3 item' ) ;
220+ assert . strictEqual ( items [ 3 ] . id , 4 , '4 item' ) ;
215221 } ) ;
216222
217223 test ( 'dataSource runtime change should be correct even if remove was pushed to the previous dataSource' , function ( assert ) {
218224 const data = [ ...helper . data ] ;
225+
219226 helper . store . push ( [ { type : 'remove' , key : 0 } ] ) ;
220227
221228 const newDataSource = new DataSource ( {
222229 load : ( e ) => data . sort ( ( a , b ) => a . index - b . index ) ,
223230 loadMode : 'raw' ,
224231 pageSize : 2 ,
225232 pushAggregationTimeout : 0 ,
233+ reshapeOnPush : true ,
226234 key : 'id'
227235 } ) ;
228236 helper . instance . option ( 'dataSource' , newDataSource ) ;
@@ -231,7 +239,7 @@ module('live update', {
231239 assert . strictEqual ( items [ 0 ] . id , 0 , '0 item' ) ;
232240 assert . strictEqual ( items [ 1 ] . id , 1 , '1 item' ) ;
233241
234- helper . instance . loadNextPage ( ) ;
242+ helper . instance . _loadNextPage ( ) ;
235243
236244 items = helper . getItems ( ) ;
237245 assert . strictEqual ( items [ 2 ] . id , 2 , '2 item' ) ;
0 commit comments