diff options
author | Carson Gross <carson@bigsky.software> | 2022-10-30 13:49:29 -0600 |
---|---|---|
committer | Carson Gross <carson@bigsky.software> | 2022-10-30 13:49:29 -0600 |
commit | 84d8e33deb8ca59b6eb30cf37b42f4475a3c4e4f (patch) | |
tree | 6a41d179bac74cb0b1d5275fe8503cbed028031f /test/core/api.js | |
parent | d16cf3c9bbaf70bb52cc75dcf592f0851554aa5e (diff) | |
download | htmx-84d8e33deb8ca59b6eb30cf37b42f4475a3c4e4f.tar.gz htmx-84d8e33deb8ca59b6eb30cf37b42f4475a3c4e4f.zip |
fix tests
Diffstat (limited to 'test/core/api.js')
-rw-r--r-- | test/core/api.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/core/api.js b/test/core/api.js index 5e4f26c1..aea3fa24 100644 --- a/test/core/api.js +++ b/test/core/api.js @@ -8,20 +8,24 @@ describe("Core htmx API test", function(){ clearWorkArea(); }); - it('onLoad is called... onLoad', function(){ + it('onLoad is called... onLoad', function(done){ // also tests on/off this.server.respondWith("GET", "/test", "<div id='d1' hx-get='/test'></div>") var helper = htmx.onLoad(function (elt) { elt.setAttribute("foo", "bar"); }); - try { - var div = make("<div id='d1' hx-get='/test' hx-swap='outerHTML'></div>"); - div.click(); - this.server.respond(); - byId("d1").getAttribute("foo").should.equal("bar"); - } finally { - htmx.off("htmx:load", helper); - } + var server = this.server; + setTimeout(function() { + try { + var div = make("<div id='d1' hx-get='/test' hx-swap='outerHTML'></div>"); + div.click(); + server.respond(); + byId("d1").getAttribute("foo").should.equal("bar"); + done(); + } finally { + htmx.off("htmx:load", helper); + } + }, 10) }); it('triggers properly', function () { |