@@ -1062,4 +1062,66 @@ describe('uiScroll', function () {
10621062
10631063 } ) ;
10641064
1065+ describe ( 'adapter reload tests' , function ( ) {
1066+ var scrollSettings = { datasource : 'myInfiniteDatasource' , adapter : 'adapter' } ;
1067+
1068+ it ( 'initial load should be positioned at item#1' , function ( ) {
1069+ runTest ( scrollSettings ,
1070+ function ( viewport , scope , $timeout ) {
1071+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1072+ }
1073+ ) ;
1074+ } )
1075+
1076+ it ( 'reload(100) should position it at item#100' , function ( ) {
1077+ runTest ( scrollSettings ,
1078+ function ( viewport , scope , $timeout ) {
1079+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1080+
1081+ scope . adapter . reload ( 100 ) ;
1082+ $timeout . flush ( ) ;
1083+
1084+ expect ( scope . adapter . topVisible ) . toBe ( 'item100' ) ;
1085+ }
1086+ ) ;
1087+ } )
1088+
1089+ it ( 'reload() should position it at item#1' , function ( ) {
1090+ runTest ( scrollSettings ,
1091+ function ( viewport , scope , $timeout ) {
1092+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1093+
1094+ scope . adapter . reload ( 100 ) ;
1095+ $timeout . flush ( ) ;
1096+
1097+ expect ( scope . adapter . topVisible ) . toBe ( 'item100' ) ;
1098+
1099+ scope . adapter . reload ( ) ;
1100+ $timeout . flush ( ) ;
1101+
1102+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1103+ }
1104+ ) ;
1105+ } )
1106+
1107+ it ( 'reload(0) should position it at item#0' , function ( ) {
1108+ runTest ( scrollSettings ,
1109+ function ( viewport , scope , $timeout ) {
1110+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1111+
1112+ scope . adapter . reload ( 100 ) ;
1113+ $timeout . flush ( ) ;
1114+
1115+ expect ( scope . adapter . topVisible ) . toBe ( 'item100' ) ;
1116+
1117+ scope . adapter . reload ( 0 ) ;
1118+ $timeout . flush ( ) ;
1119+
1120+ expect ( scope . adapter . topVisible ) . toBe ( 'item0' ) ;
1121+ }
1122+ ) ;
1123+ } )
1124+
1125+ } ) ;
1126+
10651127} ) ;
0 commit comments