@@ -171,6 +171,8 @@ describe("IAS", function () {
171
171
// register listener
172
172
. on ( 'noneLeft' , spy1 ) ;
173
173
174
+ expect ( spy1 ) . not . toHaveBeenCalled ( ) ;
175
+
174
176
// scroll to page 2
175
177
scrollDown ( ) . then ( function ( ) {
176
178
wait ( 2000 ) . then ( function ( ) {
@@ -190,22 +192,55 @@ describe("IAS", function () {
190
192
return deferred . promise ;
191
193
} ) ;
192
194
193
- it ( "should call noneLeft listeners when content is short without next" , function ( ) {
195
+ it ( "should call noneLeft listeners when content is short without next (before init) " , function ( ) {
194
196
var deferred = when . defer ( ) ;
195
197
var spy1 = this . spy ( ) ;
196
198
197
199
jQuery . ias ( 'destroy' ) ;
198
200
199
201
loadFixture ( "short-without-next.html" , function ( ) {
200
- jQuery . ias ( {
202
+ var ias = jQuery . ias ( {
201
203
container : '.listing' ,
202
204
item : '.post' ,
203
205
pagination : '.navigation' ,
204
206
next : '.next-posts a' ,
205
- initialize : true
206
- } )
207
- // register listener
208
- . on ( 'noneLeft' , spy1 ) ;
207
+ initialize : false
208
+ } ) ;
209
+
210
+ // register listener
211
+ ias . on ( 'noneLeft' , spy1 ) ;
212
+
213
+ expect ( spy1 ) . not . toHaveBeenCalled ( ) ;
214
+
215
+ ias . initialize ( ) ;
216
+
217
+ expect ( spy1 ) . toHaveBeenCalledOnce ( ) ;
218
+
219
+ deferred . resolve ( ) ;
220
+ } ) ;
221
+
222
+ return deferred . promise ;
223
+ } ) ;
224
+
225
+ it ( "should call noneLeft listeners when content is short without next (after init)" , function ( ) {
226
+ var deferred = when . defer ( ) ;
227
+ var spy1 = this . spy ( ) ;
228
+
229
+ jQuery . ias ( 'destroy' ) ;
230
+
231
+ loadFixture ( "short-without-next.html" , function ( ) {
232
+ var ias = jQuery . ias ( {
233
+ container : '.listing' ,
234
+ item : '.post' ,
235
+ pagination : '.navigation' ,
236
+ next : '.next-posts a' ,
237
+ initialize : false
238
+ } ) ;
239
+
240
+ ias . initialize ( ) ;
241
+
242
+ // register listener
243
+ ias . on ( 'noneLeft' , spy1 ) ;
209
244
210
245
expect ( spy1 ) . toHaveBeenCalledOnce ( ) ;
211
246
0 commit comments