Skip to content

Commit

Permalink
Add ARIA testing
Browse files Browse the repository at this point in the history
Added new test suite for testing the ARIA-invalid features
Also added a few minor fixes for typos in the QUnit scaffolding and
JSHint errors
Fix "%o has no name assigned [object HTMLInputElement]" errors in bypassValidation tests
  • Loading branch information
nschonni authored and jzaefferer committed Oct 7, 2013
1 parent 600e292 commit 3d5658e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
11 changes: 4 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ grunt.initConfig({
},
files: {
src: [
'test/test.js',
'test/rules.js',
'test/messages.js',
'test/methods.js'
'test/*.js'
]
}
},
Expand All @@ -116,11 +113,11 @@ grunt.initConfig({
},
src: {
files: '<%= jshint.files %>',
tasks: ['concat']
tasks: ['concat', 'qunit']
},
test: {
files: '<%= jshint.test.files.src %>',
tasks: ['jshint:test', 'qunit']
files: ['<%= jshint.test.files.src %>', 'test/index.html'],
tasks: ['jshint:test']
}
}
});
Expand Down
27 changes: 27 additions & 0 deletions test/aria.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module("aria");

test("Invalid field adds aria-invalid=true", function() {
var ariafirstname = $('#ariafirstname');
var form = $('#ariaInvalid');
form.validate({
rules: {
ariafirstname: 'required'
}
});
ariafirstname.val('');
ariafirstname.valid();
equal(ariafirstname.attr('aria-invalid'), "true");
});

test("Valid field adds aria-invalid=false", function() {
var ariafirstname = $('#ariafirstname');
var form = $("#ariaInvalid");
form.validate({
rules: {
ariafirstname: "required"
}
});
ariafirstname.val('not empty');
ariafirstname.valid();
equal(ariafirstname.attr("aria-invalid"), "false");
});
11 changes: 8 additions & 3 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<script src="rules.js"></script>
<script src="messages.js"></script>
<script src="methods.js"></script>
<script src="aria.js"></script>
</head>
<body id="body">
<h1 id="qunit-header">
Expand Down Expand Up @@ -280,7 +281,7 @@ <h3></h3>
<input class="required" name="hastitle" type="text" title="fromtitle" />
</form>

<form id="ccform" method="get" action="">
<form id="ccform" method="get">
<input id="cardnumber" name="cardnumber" />
</form>

Expand Down Expand Up @@ -320,7 +321,7 @@ <h3></h3>
<input id="rangeAbsentInvalidLess" name="rangeAbsentInvalidLess" min="200" max="1000" value="50"/>

<input type="text" id="rangeTextValid" name="rangeTextValid" min="50" max="1000" value="200"/>
<input id="rangeAbsentValid" name="rangeTextValid" min="50" max="1000" value="200"/>
<input id="rangeAbsentValid" name="rangeAbsentValid" min="50" max="1000" value="200"/>

<!-- ranges are like numbers in html5, except that browser is not required
to demand an exact value. User interface could be a slider.
Expand All @@ -337,12 +338,16 @@ <h3></h3>
</form>

<form id="bypassValidation">
<input type="text" required/>
<input type="text" name="bypassValidationRequiredInput" required/>
<input id="normalSubmit" type="submit" value="submit"/>
<input id="bypassSubmitWithCancel" type="submit" class="cancel" value="bypass1"/>
<input id="bypassSubmitWithNoValidate1" type="submit" formnovalidate value="bypass1"/>
<input id="bypassSubmitWithNoValidate2" type="submit" formnovalidate="formnovalidate" value="bypass2"/>
</form>

<form id="ariaInvalid">
<input type="text" name="ariafirstname" id="ariafirstname" />
</form>
</div>

</body>
Expand Down
4 changes: 2 additions & 2 deletions test/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ for ( ; i < length; i++ ) {
}
}

if (version != "git") {
if (version !== "git") {
file = "../lib/jquery-" + version + ".js";
}


//jshint -W060
document.write( "<script src='" + file + "'></script>" );

})();

0 comments on commit 3d5658e

Please sign in to comment.