mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-04-05 02:03:56 +00:00
fix test - had to turn off the sinon fake server and issue a real garbage request, and rewrite it as an async test
This commit is contained in:
@@ -172,22 +172,19 @@ describe("Core htmx Events", function() {
|
||||
}
|
||||
});
|
||||
|
||||
it("htmx:sendError is called after a failed request", function () {
|
||||
it("htmx:sendError is called after a failed request", function (done) {
|
||||
var called = false;
|
||||
var handler = htmx.on("htmx:sendError", function (evt) {
|
||||
called = true;
|
||||
});
|
||||
try {
|
||||
this.server.respondWith("POST", "/test", function (xhr) {
|
||||
xhr.respond(200, {}, "");
|
||||
});
|
||||
var div = make("<button hx-post='/test'>Foo</button>");
|
||||
div.click();
|
||||
this.server.respond();
|
||||
should.equal(called, true);
|
||||
} finally {
|
||||
this.server.restore(); // turn off server mock so connection doesn't work
|
||||
var div = make("<button hx-post='file://foo'>Foo</button>");
|
||||
div.click();
|
||||
setTimeout(function () {
|
||||
htmx.off("htmx:sendError", handler);
|
||||
}
|
||||
should.equal(called, true);
|
||||
done();
|
||||
}, 30);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user