Skip to content

Commit

Permalink
[Test] Add a test to ensure inputs outside form with form attribute…
Browse files Browse the repository at this point in the history
… work properly (#1815)

Add a test to ensure inputs external to form work properly
  • Loading branch information
Telroshan authored Sep 21, 2023
1 parent 048f98c commit 1f55266
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/core/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,4 +1208,26 @@ describe("Core htmx AJAX Tests", function(){
this.server.respond();
values.should.deep.equal({t1: 'textValue', b1: ['inputValue', 'buttonValue']});
})

it('properly handles inputs external to form', function () {
var values;
this.server.respondWith("Post", "/test", function (xhr) {
values = getParameters(xhr);
xhr.respond(204, {}, "");
});

make('<form id="externalForm" hx-post="/test">' +
' <input type="hidden" name="b1" value="inputValue">' +
'</form>' +
'<input type="text" name="t1" value="textValue" form="externalForm">' +
'<select name="s1" form="externalForm">' +
' <option value="someValue"></option>' +
' <option value="selectValue" selected></option>' +
'</select>' +
'<button id="submit" form="externalForm" type="submit" name="b1" value="buttonValue">button</button>');

byId("submit").click();
this.server.respond();
values.should.deep.equal({t1: 'textValue', b1: ['inputValue', 'buttonValue'], s1: "selectValue"});
})
})

0 comments on commit 1f55266

Please sign in to comment.