@@ -172,22 +172,19 @@ describe('virtualizer', () => {
172172 expect ( item . getBoundingClientRect ( ) . top ) . to . equal ( scrollTarget . getBoundingClientRect ( ) . top - 10 ) ;
173173 } ) ;
174174
175- it ( 'should not request a different set of items on size increase' , ( ) => {
175+ it ( 'should not request item updates on size increase' , ( ) => {
176176 const updateElement = sinon . spy ( ( el , index ) => ( el . textContent = `item-${ index } ` ) ) ;
177177 init ( { size : 100 , updateElement } ) ;
178178
179179 // Scroll halfway down the list
180180 updateElement . resetHistory ( ) ;
181181 virtualizer . scrollToIndex ( 50 ) ;
182- const updatedIndexes = updateElement . getCalls ( ) . map ( ( call ) => call . args [ 1 ] ) ;
183182
184183 // Increase the size so it shouldn't affect the current viewport items
185184 updateElement . resetHistory ( ) ;
186185 virtualizer . size = 200 ;
187- const postResizeUpdatedIndexes = updateElement . getCalls ( ) . map ( ( call ) => call . args [ 1 ] ) ;
188186
189- expect ( postResizeUpdatedIndexes ) . to . eql ( updatedIndexes ) ;
190- expect ( postResizeUpdatedIndexes ) . not . to . include ( 0 ) ;
187+ expect ( updateElement . called ) . to . be . false ;
191188 } ) ;
192189
193190 it ( 'should request a different set of items on size decrease' , ( ) => {
@@ -208,6 +205,17 @@ describe('virtualizer', () => {
208205 expect ( postResizeUpdatedIndexes ) . to . include ( 0 ) ;
209206 } ) ;
210207
208+ it ( 'should request an index only once' , async ( ) => {
209+ const updateElement = sinon . spy ( ( el , index ) => ( el . textContent = `item-${ index } ` ) ) ;
210+ init ( { size : 100 , updateElement } ) ;
211+
212+ // Wait for a possible resize observer flush
213+ await aTimeout ( 100 ) ;
214+
215+ const firstIndexUpdatesCount = updateElement . getCalls ( ) . filter ( ( call ) => call . args [ 1 ] === 0 ) . length ;
216+ expect ( firstIndexUpdatesCount ) . to . equal ( 1 ) ;
217+ } ) ;
218+
211219 it ( 'should have physical items once visible' , async ( ) => {
212220 init ( { size : 0 } ) ;
213221 // Wait for possibly active resize observers to flush
0 commit comments