2013-02-21 02:15:50 +08:00
|
|
|
/*global waitsFor:true expect:true describe:true beforeEach:true it:true spyOn:true */
|
2013-02-28 10:26:20 +08:00
|
|
|
|
|
|
|
describe("Discourse.Onebox", function() {
|
|
|
|
|
2013-03-06 03:03:50 +08:00
|
|
|
var anchor;
|
|
|
|
|
2013-02-28 10:26:20 +08:00
|
|
|
beforeEach(function() {
|
|
|
|
spyOn(jQuery, 'ajax').andCallThrough();
|
2013-03-06 03:03:50 +08:00
|
|
|
anchor = $("<a href='http://bla.com'></a>")[0];
|
2013-02-21 02:15:50 +08:00
|
|
|
});
|
|
|
|
|
2013-02-28 10:26:20 +08:00
|
|
|
it("Stops rapid calls with cache true", function() {
|
2013-03-06 03:03:50 +08:00
|
|
|
Discourse.Onebox.load(anchor, true);
|
|
|
|
Discourse.Onebox.load(anchor, true);
|
2013-02-28 10:26:20 +08:00
|
|
|
expect(jQuery.ajax.calls.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Stops rapid calls with cache false", function() {
|
2013-03-06 03:03:50 +08:00
|
|
|
Discourse.Onebox.load(anchor, false);
|
|
|
|
Discourse.Onebox.load(anchor, false);
|
2013-02-28 10:26:20 +08:00
|
|
|
expect(jQuery.ajax.calls.length).toBe(1);
|
|
|
|
});
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2013-02-28 10:26:20 +08:00
|
|
|
});
|