Add a unit-test to check that the sortByVisibility parameter, in getVisibleElements, works correctly
				
					
				
			This commit is contained in:
		
							parent
							
								
									9743708a24
								
							
						
					
					
						commit
						b2235ec9c4
					
				| @ -690,6 +690,34 @@ describe('ui_utils', function() { | ||||
|       scrollOverDocument(pages, true); | ||||
|     }); | ||||
| 
 | ||||
|     it('handles `sortByVisibility` correctly', function() { | ||||
|       const scrollEl = { | ||||
|         scrollTop: 75, | ||||
|         scrollLeft: 0, | ||||
|         clientHeight: 750, | ||||
|         clientWidth: 1500, | ||||
|       }; | ||||
|       const views = makePages([ | ||||
|         [[100, 150]], | ||||
|         [[100, 150]], | ||||
|         [[100, 150]], | ||||
|       ]); | ||||
| 
 | ||||
|       const visible = getVisibleElements(scrollEl, views); | ||||
|       const visibleSorted = getVisibleElements(scrollEl, views, | ||||
|                                                /* sortByVisibility = */ true); | ||||
| 
 | ||||
|       const viewsOrder = [], viewsSortedOrder = []; | ||||
|       for (const view of visible.views) { | ||||
|         viewsOrder.push(view.id); | ||||
|       } | ||||
|       for (const view of visibleSorted.views) { | ||||
|         viewsSortedOrder.push(view.id); | ||||
|       } | ||||
|       expect(viewsOrder).toEqual([0, 1, 2]); | ||||
|       expect(viewsSortedOrder).toEqual([1, 2, 0]); | ||||
|     }); | ||||
| 
 | ||||
|     it('handles views being empty', function() { | ||||
|       const scrollEl = { | ||||
|         scrollTop: 10, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user