mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 13:31:06 +00:00
new afterOnLoad and afterRequest tests
To make sure these are fired when using outerHTML swapping
This commit is contained in:
parent
8983448b33
commit
da1707b5a0
@ -189,6 +189,42 @@ describe("Core htmx Events", function() {
|
||||
htmx.off("htmx:sendError", handler);
|
||||
}
|
||||
});
|
||||
|
||||
it("htmx:afterRequest is called when replacing outerHTML", function () {
|
||||
var called = false;
|
||||
var handler = htmx.on("htmx:afterRequest", function (evt) {
|
||||
called = true;
|
||||
});
|
||||
try {
|
||||
this.server.respondWith("POST", "/test", function (xhr) {
|
||||
xhr.respond(200, {}, "<button>Bar</button>");
|
||||
});
|
||||
var div = make("<button hx-post='/test' hx-swap='outerHTML'>Foo</button>");
|
||||
div.click();
|
||||
this.server.respond();
|
||||
should.equal(called, true);
|
||||
} finally {
|
||||
htmx.off("htmx:afterRequest", handler);
|
||||
}
|
||||
});
|
||||
|
||||
it("htmx:afterOnLoad is called when replacing outerHTML", function () {
|
||||
var called = false;
|
||||
var handler = htmx.on("htmx:afterOnLoad", function (evt) {
|
||||
called = true;
|
||||
});
|
||||
try {
|
||||
this.server.respondWith("POST", "/test", function (xhr) {
|
||||
xhr.respond(200, {}, "<button>Bar</button>");
|
||||
});
|
||||
var div = make("<button hx-post='/test' hx-swap='outerHTML'>Foo</button>");
|
||||
div.click();
|
||||
this.server.respond();
|
||||
should.equal(called, true);
|
||||
} finally {
|
||||
htmx.off("htmx:afterOnLoad", handler);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user