Skip to content

Commit ada44e5

Browse files
committed
Merge pull request #199 from mindgrub-mmirchandani/feature/render-call-callback
Feature/render call callback
2 parents 7380f74 + dae1879 commit ada44e5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/jquery-ias.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@
245245
}
246246
});
247247
});
248+
249+
promise.fail(function() {
250+
if (callback) {
251+
callback();
252+
}
253+
});
248254
};
249255

250256
/**

test/04-paging-extension-test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,24 @@ describe("IAS", function () {
4444

4545
return deferred.promise;
4646
});
47+
48+
it("callbacks should be called when render returns false", function() {
49+
var deferred = when.defer();
50+
var spy1 = this.spy();
51+
52+
jQuery.ias().on('render', function() { spy1(); return false; });
53+
// If the user uses their own render function (which returns false), then IAS
54+
// doesn't call other render callbacks such as the one that sets the next URL
55+
// This is tested by adding our own render callback and then adding checks to
56+
// confirm the render callback actually did run and the nextUrl has been updated.
57+
scrollDown().then(function() {
58+
wait(2000).then(function() {
59+
expect(spy1).toHaveBeenCalledOnce();
60+
buster.assert.contains(jQuery.ias().nextUrl, "page3.html");
61+
62+
deferred.resolve();
63+
})
64+
})
65+
return deferred.promise;
66+
});
4767
});

0 commit comments

Comments
 (0)