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