mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
Fix onebox loading on every keystroke after a request fails.
This commit is contained in:
@ -2,19 +2,22 @@
|
||||
|
||||
describe("Discourse.Onebox", function() {
|
||||
|
||||
var anchor;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(jQuery, 'ajax').andCallThrough();
|
||||
anchor = $("<a href='http://bla.com'></a>")[0];
|
||||
});
|
||||
|
||||
it("Stops rapid calls with cache true", function() {
|
||||
Discourse.Onebox.lookup('http://bla.com', true, function(c) { return c; });
|
||||
Discourse.Onebox.lookup('http://bla.com', true, function(c) { return c; });
|
||||
Discourse.Onebox.load(anchor, true);
|
||||
Discourse.Onebox.load(anchor, true);
|
||||
expect(jQuery.ajax.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it("Stops rapid calls with cache false", function() {
|
||||
Discourse.Onebox.lookup('http://bla.com/a', false, function(c) { return c; });
|
||||
Discourse.Onebox.lookup('http://bla.com/a', false, function(c) { return c; });
|
||||
Discourse.Onebox.load(anchor, false);
|
||||
Discourse.Onebox.load(anchor, false);
|
||||
expect(jQuery.ajax.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user