Qunit and the Validation Plugin

Qunit and the Validation Plugin


Given this form and elements:
<form id="aspnetForm" action="#">
<input type="text" id="nameInputId" />
<input type="text" id="abbreviationInputId" />
</form>
I cannot get the following test to pass
$(document).ready(function() {
test("testing validation", function() {
// arrange
$("#nameInputId").val("");
$("#abbreviationInputId").val("not empty");
// act
$("#aspnetForm").validate();
$("#abbreviationInputId").rules("add", { required: true });
var rules = $("#nameInputId").rules();
// assert
expect(4);
equals(rules.required, null);
equals($("#aspnetForm").validate().element("#nameInputId"), true);
equals($("#aspnetForm").validate().element
("#abbreviationInputId"), true);
equals($("#aspnetForm").valid(), true);
});
});
I'm using Qunit version: jqueryjs - Revision 6323: /trunk/qunit
jquery version jquery-1.3.2.min.js
jquery plugin: Validation v1.5.2
For some reason, although I am specifically adding the required method
to
the abbreviationInput element it is also being added to the nameInput
element.
At first I thought the problem was with the validation plugin but this
actually
works as expected when not using Qunit.
Any thoughts or insight would be very appreciated.
Thanks!
Gary Brunton