@@ -46,7 +46,7 @@ QUnit.test( 'checkLastPage', function( assert ) {
46
46
scrollThreshold : false ,
47
47
history : false ,
48
48
} ) ;
49
-
49
+
50
50
infScroll . on ( 'last' , onStringLast1 ) ;
51
51
infScroll . once ( 'append' , onStringAppend1 ) ;
52
52
infScroll . loadNextPage ( ) ;
@@ -66,6 +66,47 @@ QUnit.test( 'checkLastPage', function( assert ) {
66
66
function loadStringPage3 ( ) {
67
67
infScroll . once ( 'last' , function ( ) {
68
68
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' ) ;
69
110
done ( ) ;
70
111
} ) ;
71
112
0 commit comments