diff --git a/test/core/ajax.js b/test/core/ajax.js index ae33fd53..3f4e740b 100644 --- a/test/core/ajax.js +++ b/test/core/ajax.js @@ -969,15 +969,15 @@ describe("Core htmx AJAX Tests", function(){ it('scripts w/ src attribute are properly loaded', function(done) { try { - this.server.respondWith("GET", "/test", ""); + this.server.respondWith("GET", "/test", ""); var div = make("
"); div.click(); this.server.respond(); - setTimeout(function () { + byId("setGlobalScript").addEventListener("load", function () { window.globalWasCalled.should.equal(true); delete window.globalWasCalled; done(); - }, 400); + }) } finally { delete window.globalWasCalled; } diff --git a/test/core/parameters.js b/test/core/parameters.js index b7d74ba3..fa6f6257 100644 --- a/test/core/parameters.js +++ b/test/core/parameters.js @@ -123,26 +123,34 @@ describe("Core htmx Parameter Handling", function() { htmx._("urlEncode")({"foo": "bar", "do" : ["rey", "blah"]}).should.equal("foo=bar&do=rey&do=blah"); }); - it('form includes last focused button', function () { + it('form includes last focused button', function (done) { var form = make(''); var input = byId('i1'); var button = byId('b1'); + // Listen for focusin on form as it'll bubble up from the button, and htmx binds on the form itself + form.addEventListener("focusin", function () { + var vals = htmx._('getInputValues')(form).values; + vals['foo'].should.equal('bar'); + vals['do'].should.equal('rey'); + vals['btn'].should.equal('bar'); + done(); + }); button.focus(); - var vals = htmx._('getInputValues')(form).values; - vals['foo'].should.equal('bar'); - vals['do'].should.equal('rey'); - vals['btn'].should.equal('bar'); }) - it('form includes last focused submit', function () { + it('form includes last focused submit', function (done) { var form = make(''); var input = byId('i1'); var button = byId('s1'); + // Listen for focusin on form as it'll bubble up from the button, and htmx binds on the form itself + form.addEventListener("focusin", function () { + var vals = htmx._('getInputValues')(form).values; + vals['foo'].should.equal('bar'); + vals['do'].should.equal('rey'); + vals['s1'].should.equal('bar'); + done(); + }); button.focus(); - var vals = htmx._('getInputValues')(form).values; - vals['foo'].should.equal('bar'); - vals['do'].should.equal('rey'); - vals['s1'].should.equal('bar'); }) it('form does not include button when focus is lost', function () { diff --git a/test/core/security.js b/test/core/security.js index 241c4526..95f17350 100644 --- a/test/core/security.js +++ b/test/core/security.js @@ -107,6 +107,7 @@ describe("security options", function() { }) it("can make egress cross site requests when htmx.config.selfRequestsOnly is enabled", function(done){ + this.timeout(4000) // should trigger send error, rather than reject var listener = htmx.on("htmx:sendError", function (){ htmx.off("htmx:sendError", listener); @@ -119,6 +120,7 @@ describe("security options", function() { }) it("can't make egress cross site requests when htmx.config.selfRequestsOnly is enabled", function(done){ + this.timeout(4000) // should trigger send error, rather than reject htmx.config.selfRequestsOnly = true; var listener = htmx.on("htmx:invalidPath", function (){ @@ -133,6 +135,7 @@ describe("security options", function() { }) it("can cancel egress request based on htmx:validateUrl event", function(done){ + this.timeout(4000) // should trigger send error, rather than reject var pathVerifier = htmx.on("htmx:validateUrl", function (evt){ evt.preventDefault(); @@ -149,6 +152,7 @@ describe("security options", function() { }) it("can cancel egress request based on htmx:validateUrl event, sameHost is false", function(done){ + this.timeout(4000) // should trigger send error, rather than reject var pathVerifier = htmx.on("htmx:validateUrl", function (evt){ if (evt.detail.sameHost === false) { diff --git a/test/index.html b/test/index.html index 6da68a49..f747775b 100644 --- a/test/index.html +++ b/test/index.html @@ -161,8 +161,10 @@ Work Area