-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2676 - Tests for v2 to prevent regression of issue from v1 #2829
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,42 @@ describe('Core htmx client side validation tests', function() { | |
form.textContent.should.equal('Clicked!') | ||
}) | ||
|
||
it('Custom validation error prevents request for unticked checkboxes', function() { | ||
this.server.respondWith('POST', '/test', 'Clicked!') | ||
|
||
var form = make('<form hx-post="/test" hx-trigger="click">' + | ||
'No Request' + | ||
'<input id="i1" name="i1" type="checkbox">' + | ||
'</form>') | ||
byId('i1').setCustomValidity('Nope') | ||
form.textContent.should.equal('No Request') | ||
form.click() | ||
this.server.respond() | ||
form.textContent.should.equal('No Request') | ||
byId('i1').setCustomValidity('') | ||
form.click() | ||
this.server.respond() | ||
form.textContent.should.equal('Clicked!') | ||
}) | ||
|
||
it('Custom validation error prevents request for unselected radiogroups', function() { | ||
this.server.respondWith('POST', '/test', 'Clicked!') | ||
|
||
var form = make('<form hx-post="/test" hx-trigger="click">' + | ||
'No Request' + | ||
'<input id="i1" name="i1" type="radio">' + | ||
'</form>') | ||
byId('i1').setCustomValidity('Nope') | ||
form.textContent.should.equal('No Request') | ||
form.click() | ||
this.server.respond() | ||
form.textContent.should.equal('No Request') | ||
byId('i1').setCustomValidity('') | ||
form.click() | ||
this.server.respond() | ||
form.textContent.should.equal('Clicked!') | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two functions are essentially clones of the previous function but applied specifically to the input types with special handling in |
||
it('hyperscript validation error prevents request', function() { | ||
this.server.respondWith('POST', '/test', 'Clicked!') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is essentially just a cut-down clone of the function above which tests checkboxes in detail, to cover the
shouldInclude
logic which applies to both input types:if (elt.type === 'checkbox' || elt.type === 'radio') { return elt.checked }