import { VirtualScrollPage } from './virtual-scroll.po.spec' ; describe ( 'Virtual Scroll Tests' , ( ) => { let page ; beforeEach ( async ( ) => { page = new VirtualScrollPage ( ) ; await page . getPage ( ) ; } ) ; it ( 'should have correct initial states' , async ( ) => { expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeFalsy ( ) ; expect ( await page . confirmLoadOnScrollIsChecked ( ) ) . toBeTruthy ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '8' ) ; } ) ; it ( 'should display the correct employee details' , async ( ) => { for ( var i = 0 ; i < 4 ; i ++ ) { expect ( await page . getEmployeeText ( i ) ) . toBe ( 'Employee_' + i ) ; } for ( i = 0 ; i < 4 ; i ++ ) { expect ( await page . getDepartmentText ( i ) ) . toBe ( '(Department_' + i + ')' ) ; } for ( i = 0 ; i < 4 ; i ++ ) { expect ( await page . getEmailText ( i ) ) . toBe ( 'employee.' + i + '@business.com' ) ; } for ( i = 0 ; i < 4 ; i ++ ) { expect ( await page . getEmployeeIDNumber ( i ) ) . toBe ( i . toString ( ) ) ; } } ) ; it ( 'should react to clicking on the loadOnScroll checkbox' , async ( ) => { await page . clickOnLoadOnScroll ( ) ; expect ( await page . confirmLoadOnScrollIsChecked ( ) ) . toBeFalsy ( ) ; await page . clickOnLoadOnScroll ( ) ; expect ( await page . confirmLoadOnScrollIsChecked ( ) ) . toBeTruthy ( ) ; } ) ; it ( 'should display more employees when the LOAD MORE button is clicked' , async ( ) => { await page . clickOnLoadOnScroll ( ) ; await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '1999' ) ; await page . loadMoreButton . click ( ) ; await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '3999' ) ; await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '3999' ) ; await page . loadMoreButton . click ( ) ; await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '5999' ) ; } ) ; it ( 'should display the LOAD MORE button when appropriate' , async ( ) => { await page . clickOnLoadOnScroll ( ) ; expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeTruthy ( ) ; await page . clickOnLoadOnScroll ( ) ; expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeFalsy ( ) ; await page . clickOnLoadOnScroll ( ) ; for ( var i = 0 ; i < 9 ; i ++ ) { await page . scrollToEnd ( ) ; expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeTruthy ( ) ; await page . loadMoreButton . click ( ) ; } await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '19999' ) ; expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeTruthy ( ) ; await page . loadMoreButton . click ( ) ; await page . scrollToEnd ( ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '21999' ) ; expect ( await page . confirmLoadMoreIsVisible ( ) ) . toBeFalsy ( ) ; } ) ; it ( 'should display more employees when scrolling down' , async ( ) => { await page . scrollToEnd ( ) ; await page . waitForLastVisibleEmployeeId ( '2009' ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '2009' ) ; await page . scrollToEnd ( ) ; await page . waitForLastVisibleEmployeeId ( '4009' ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '4009' ) ; await page . scrollToEnd ( ) ; await page . waitForLastVisibleEmployeeId ( '6009' ) ; expect ( await page . getLastVisibleEmployeeIDNumber ( ) ) . toBe ( '6009' ) ; } ) ; } ) ;