@@ -1096,6 +1096,45 @@ describe('uiScroll', function () {
10961096 ) ;
10971097 } ) ;
10981098
1099+ it ( 'should round numbers for startIndex' , ( ) => {
1100+ runTest ( scrollSettings ,
1101+ function ( viewport , scope ) {
1102+ scope . adapter . reload ( 23.4 ) ;
1103+ expect ( scope . adapter . topVisible ) . toBe ( 'item23' ) ;
1104+
1105+ scope . adapter . reload ( - 56.9 ) ;
1106+ expect ( scope . adapter . topVisible ) . toBe ( 'item-57' ) ;
1107+ }
1108+ ) ;
1109+ } ) ;
1110+
1111+ it ( 'should correctly convert string to number and round' , ( ) => {
1112+ runTest ( scrollSettings ,
1113+ function ( viewport , scope ) {
1114+ scope . adapter . reload ( '1001.14' ) ;
1115+ expect ( scope . adapter . topVisible ) . toBe ( 'item1001' ) ;
1116+
1117+ scope . adapter . reload ( '0' ) ;
1118+ expect ( scope . adapter . topVisible ) . toBe ( 'item0' ) ;
1119+ }
1120+ ) ;
1121+ } ) ;
1122+
1123+ it ( 'should set startIndex to default if number is invalid' , ( ) => {
1124+ runTest ( scrollSettings ,
1125+ function ( viewport , scope ) {
1126+ scope . adapter . reload ( 'invalid number' ) ;
1127+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1128+
1129+ scope . adapter . reload ( { } ) ;
1130+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1131+
1132+ scope . adapter . reload ( null ) ;
1133+ expect ( scope . adapter . topVisible ) . toBe ( 'item1' ) ;
1134+ }
1135+ ) ;
1136+ } ) ;
1137+
10991138 } ) ;
11001139
11011140 describe ( 'adapter bof/eof/empty' , function ( ) {
0 commit comments