@@ -46,7 +46,7 @@ QUnit.test( 'checkLastPage', function( assert ) {
4646 scrollThreshold : false ,
4747 history : false ,
4848 } ) ;
49-
49+
5050 infScroll . on ( 'last' , onStringLast1 ) ;
5151 infScroll . once ( 'append' , onStringAppend1 ) ;
5252 infScroll . loadNextPage ( ) ;
@@ -66,6 +66,47 @@ QUnit.test( 'checkLastPage', function( assert ) {
6666 function loadStringPage3 ( ) {
6767 infScroll . once ( 'last' , function ( ) {
6868 assert . ok ( true , 'checkLastPage: \'string\', last triggered on 3rd page' ) ;
69+ setTimeout ( checkPathFunction ) ;
70+ } ) ;
71+
72+ infScroll . loadNextPage ( ) ;
73+ }
74+
75+ // ----- path: function ----- //
76+
77+ function checkPathFunction ( ) {
78+ infScroll . destroy ( ) ;
79+ infScroll = new InfiniteScroll ( '.demo--check-last-page' , {
80+ // provide only page/2.html, then falsy
81+ path : function ( ) {
82+ if ( this . loadCount === 0 ) {
83+ var nextIndex = this . loadCount + 2 ;
84+ return 'page/' + nextIndex + '.html' ;
85+ }
86+ } ,
87+ checkLastPage : true ,
88+ append : '.post' ,
89+ scrollThreshold : false ,
90+ history : false ,
91+ } ) ;
92+
93+ infScroll . on ( 'last' , onFunctionLast2 ) ;
94+ infScroll . once ( 'append' , onFunctionAppend2 ) ;
95+
96+ infScroll . loadNextPage ( ) ;
97+ }
98+
99+ function onFunctionLast2 ( ) {
100+ assert . ok ( false , 'last should not trigger on function page 2' ) ;
101+ }
102+
103+ function onFunctionAppend2 ( ) {
104+ infScroll . off ( 'last' , onFunctionLast2 ) ;
105+
106+ infScroll . on ( 'last' , function ( response , path ) {
107+ assert . ok ( true , 'path: function, last triggered' ) ;
108+ assert . ok ( response , 'path: function, response there on last' ) ;
109+ assert . ok ( path , 'path: function, path there on last' ) ;
69110 done ( ) ;
70111 } ) ;
71112
0 commit comments