Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update testsuite to use equal and deepEqual. Fix tests that the fix for

#219 (732f5ff) broke. The element method now returns true for dependency-mismatch, that's fine.
  • Loading branch information...
commit c243e8ee8870dc45e831808a40cb17cda01b72fc 1 parent ccca8f6
@jzaefferer jzaefferer authored
Showing with 184 additions and 184 deletions.
  1. +6 −6 test/messages.js
  2. +17 −17 test/methods.js
  3. +43 −43 test/rules.js
  4. +118 −118 test/test.js
View
12 test/messages.js
@@ -4,7 +4,7 @@ test("predefined message not overwritten by addMethod(a, b, undefined)", functio
var message = "my custom message";
$.validator.messages.custom = message;
$.validator.addMethod("custom", function() {});
- same(message, $.validator.messages.custom);
+ deepEqual(message, $.validator.messages.custom);
delete $.validator.messages.custom;
delete $.validator.methods.custom;
});
@@ -26,13 +26,13 @@ test("group error messages", function() {
}
});
ok( !form.valid() );
- equals( 1, form.find(".errorContainer *").length );
- equals( "Please enter a valid date.", form.find(".errorContainer label.error").text() );
+ equal( 1, form.find(".errorContainer *").length );
+ equal( "Please enter a valid date.", form.find(".errorContainer label.error").text() );
$("#fromDate").val("12/03/2006");
$("#toDate").val("12/01/2006");
ok( !form.valid() );
- equals( "Please specify a correct date range.", form.find(".errorContainer label.error").text() );
+ equal( "Please specify a correct date range.", form.find(".errorContainer label.error").text() );
$("#toDate").val("12/04/2006");
ok( form.valid() );
@@ -44,9 +44,9 @@ test("read messages from metadata", function() {
form.validate();
var e = $("#testEmail9")
e.valid();
- equals( form.find("label").text(), "required" );
+ equal( form.find("label").text(), "required" );
e.val("bla").valid();
- equals( form.find("label").text(), "email" );
+ equal( form.find("label").text(), "email" );
});
View
34 test/methods.js
@@ -354,8 +354,8 @@ test("accept", function() {
var v = jQuery("#form").validate(),
method = function(value, param) {
- return $.validator.methods.accept.call(v, value, $('#text1')[0], param)
- };
+ return $.validator.methods.accept.call(v, value, $('#text1')[0], param);
+ };
ok( method( "picture.doc", "doc"), "Valid custom accept type" );
ok( method( "picture.pdf", "doc|pdf"), "Valid custom accept type" );
ok( method( "picture.pdf", "pdf|doc"), "Valid custom accept type" );
@@ -390,21 +390,21 @@ test("remote", function() {
});
$(document).ajaxStop(function() {
$(document).unbind("ajaxStop");
- equals( 1, v.size(), "There must be one error" );
- equals( "Peter in use", v.errorList[0].message );
+ equal( 1, v.size(), "There must be one error" );
+ equal( "Peter in use", v.errorList[0].message );
$(document).ajaxStop(function() {
$(document).unbind("ajaxStop");
- equals( 1, v.size(), "There must be one error" );
- equals( "Peter2 in use", v.errorList[0].message );
+ equal( 1, v.size(), "There must be one error" );
+ equal( "Peter2 in use", v.errorList[0].message );
start();
});
e.val("Peter2");
- ok( !v.element(e), "new value, new request" );
+ strictEqual( v.element(e), true, "new value, new request; dependency-mismatch considered as valid though" );
});
- ok( !v.element(e), "invalid element, nothing entered yet" );
+ strictEqual( v.element(e), false, "invalid element, nothing entered yet" );
e.val("Peter");
- ok( !v.element(e), "still invalid, because remote validation must block until it returns" );
+ strictEqual( v.element(e), true, "still invalid, because remote validation must block until it returns; dependency-mismatch considered as valid though" );
});
test("remote, customized ajax options", function() {
@@ -418,8 +418,8 @@ test("remote, customized ajax options", function() {
url: "users.php",
type: "POST",
beforeSend: function(request, settings) {
- same(settings.type, "POST");
- same(settings.data, "username=asdf&email=email.com");
+ deepEqual(settings.type, "POST");
+ deepEqual(settings.data, "username=asdf&email=email.com");
},
data: {
email: function() {
@@ -460,15 +460,15 @@ test("remote extensions", function() {
});
$(document).ajaxStop(function() {
$(document).unbind("ajaxStop");
- equals( 1, v.size(), "There must be one error" );
- equals( v.errorList[0].message, "asdf is already taken, please try something else" );
+ equal( 1, v.size(), "There must be one error" );
+ equal( v.errorList[0].message, "asdf is already taken, please try something else" );
v.element(e);
- equals( v.errorList[0].message, "asdf is already taken, please try something else", "message doesn't change on revalidation" );
+ equal( v.errorList[0].message, "asdf is already taken, please try something else", "message doesn't change on revalidation" );
start();
});
- ok( !v.element(e), "invalid element, nothing entered yet" );
+ strictEqual( v.element(e), false, "invalid element, nothing entered yet" );
e.val("asdf");
- ok( !v.element(e), "still invalid, because remote validation must block until it returns" );
+ strictEqual( v.element(e), true, "still invalid, because remote validation must block until it returns; dependency-mismatch considered as valid though" );
});
module("additional methods");
@@ -541,7 +541,7 @@ test("pattern", function() {
function testCardTypeByNumber(number, cardname, expected) {
$("#cardnumber").val(number);
var actual = $("#ccform").valid();
- equals(actual, expected, $.format("Expect card number {0} to validate to {1}, actually validated to ", number, expected));
+ equal(actual, expected, $.format("Expect card number {0} to validate to {1}, actually validated to ", number, expected));
}
test('creditcardtypes, all', function() {
View
86 test/rules.js
@@ -3,7 +3,7 @@ module("rules");
test("rules() - internal - input", function() {
var element = $('#firstname');
var v = $('#testForm1').validate();
- same( element.rules(), { required: true, minlength: 2 } );
+ deepEqual( element.rules(), { required: true, minlength: 2 } );
});
test("rules(), ignore method:false", function() {
@@ -13,19 +13,19 @@ test("rules(), ignore method:false", function() {
firstname: { required: false, minlength: 2 }
}
});
- same( element.rules(), { minlength: 2 } );
+ deepEqual( element.rules(), { minlength: 2 } );
});
test("rules() HTML5 required (no value)", function() {
var element = $('#testForm11text1');
var v = $('#testForm11').validate();
- same( element.rules(), { required: true } );
+ deepEqual( element.rules(), { required: true } );
});
test("rules() - internal - select", function() {
var element = $('#meal');
var v = $('#testForm3').validate();
- same( element.rules(), {required: true} );
+ deepEqual( element.rules(), {required: true} );
});
test("rules() - external", function() {
@@ -35,7 +35,7 @@ test("rules() - external", function() {
action: {date: true, min: 5}
}
});
- same( element.rules(), {date: true, min: 5} );
+ deepEqual( element.rules(), {date: true, min: 5} );
});
test("rules() - external - complete form", function() {
@@ -62,7 +62,7 @@ test("rules() - external - complete form", function() {
test("rules() - internal - input", function() {
var element = $('#form8input');
var v = $('#testForm8').validate();
- same( element.rules(), {required: true, number: true, rangelength: [2, 8]});
+ deepEqual( element.rules(), {required: true, number: true, rangelength: [2, 8]});
});
test("rules(), merge min/max to range, minlength/maxlength to rangelength", function() {
@@ -79,9 +79,9 @@ test("rules(), merge min/max to range, minlength/maxlength to rangelength", func
}
}
});
- same( $("#firstnamec").rules(), {range: [5, 12]});
+ deepEqual( $("#firstnamec").rules(), {range: [5, 12]});
- same( $("#lastnamec").rules(), {rangelength: [2, 8]} );
+ deepEqual( $("#lastnamec").rules(), {rangelength: [2, 8]} );
jQuery.validator.autoCreateRanges = false;
});
@@ -94,14 +94,14 @@ test("rules(), gurantee that required is at front", function() {
jQuery.each($(element).rules(), function(key, value) { result.push(key) });
return result.join(" ");
}
- equals( "required minlength", flatRules("#firstname") );
- equals( "required maxlength minlength", flatRules("#v2-i6") );
- equals( "required maxlength", flatRules("#co_name") );
+ equal( "required minlength", flatRules("#firstname") );
+ equal( "required maxlength minlength", flatRules("#v2-i6") );
+ equal( "required maxlength", flatRules("#co_name") );
QUnit.reset();
jQuery.validator.autoCreateRanges = true;
v = $("#v2").validate();
- equals( "required rangelength", flatRules("#v2-i6") );
+ equal( "required rangelength", flatRules("#v2-i6") );
$("#subformRequired").validate({
rules: {
@@ -109,7 +109,7 @@ test("rules(), gurantee that required is at front", function() {
}
});
$("#co_name").removeClass();
- equals( "required maxlength", flatRules("#co_name") );
+ equal( "required maxlength", flatRules("#co_name") );
jQuery.validator.autoCreateRanges = false;
});
@@ -119,13 +119,13 @@ test("rules(), evaluate dynamic parameters", function() {
rules: {
firstname: {
min: function(element) {
- equals( $("#firstnamec")[0], element );
+ equal( $("#firstnamec")[0], element );
return 12;
}
}
}
});
- same( $("#firstnamec").rules(), {min:12});
+ deepEqual( $("#firstnamec").rules(), {min:12});
});
test("rules(), class and attribute combinations", function() {
@@ -145,16 +145,16 @@ test("rules(), class and attribute combinations", function() {
}
}
});
- same( $("#v2-i1").rules(), { required: true });
- same( $("#v2-i2").rules(), { required: true, email: true });
- same( $("#v2-i3").rules(), { url: true });
- same( $("#v2-i4").rules(), { required: true, minlength: 2 });
- same( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
+ deepEqual( $("#v2-i1").rules(), { required: true });
+ deepEqual( $("#v2-i2").rules(), { required: true, email: true });
+ deepEqual( $("#v2-i3").rules(), { url: true });
+ deepEqual( $("#v2-i4").rules(), { required: true, minlength: 2 });
+ deepEqual( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
jQuery.validator.autoCreateRanges = true;
- same( $("#v2-i5").rules(), { required: true, customMethod1: "123", rangelength: [2, 5] });
- same( $("#v2-i6").rules(), { required: true, customMethod2: true, rangelength: [2, 5] });
+ deepEqual( $("#v2-i5").rules(), { required: true, customMethod1: "123", rangelength: [2, 5] });
+ deepEqual( $("#v2-i6").rules(), { required: true, customMethod2: true, rangelength: [2, 5] });
jQuery.validator.autoCreateRanges = false;
- same( $("#v2-i7").rules(), { required: true, minlength: 2, customMethod: true });
+ deepEqual( $("#v2-i7").rules(), { required: true, minlength: 2, customMethod: true });
delete $.validator.methods.customMethod1;
delete $.validator.messages.customMethod1;
@@ -185,12 +185,12 @@ test("rules(), dependency checks", function() {
});
var rules = $("#firstnamec").rules();
- equals( 0, v.objectLength(rules) );
+ equal( 0, v.objectLength(rules) );
$("#firstnamec").val('ab');
- same( $("#firstnamec").rules(), {min:5});
+ deepEqual( $("#firstnamec").rules(), {min:5});
- same( $("#lastnamec").rules(), {max:12, email:true});
+ deepEqual( $("#lastnamec").rules(), {max:12, email:true});
});
test("rules(), add and remove", function() {
@@ -199,16 +199,16 @@ test("rules(), add and remove", function() {
}, "");
$("#v2").validate();
var removedAttrs = $("#v2-i5").removeClass("required").removeAttrs("minlength maxlength");
- same( $("#v2-i5").rules(), { customMethod1: "123" });
+ deepEqual( $("#v2-i5").rules(), { customMethod1: "123" });
$("#v2-i5").addClass("required").attr(removedAttrs);
- same( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
+ deepEqual( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
$("#v2-i5").addClass("email").attr({min: 5});
- same( $("#v2-i5").rules(), { required: true, email: true, minlength: 2, maxlength: 5, min: 5, customMethod1: "123" });
+ deepEqual( $("#v2-i5").rules(), { required: true, email: true, minlength: 2, maxlength: 5, min: 5, customMethod1: "123" });
$("#v2-i5").removeClass("required email").removeAttrs("minlength maxlength customMethod1 min");
- same( $("#v2-i5").rules(), {});
+ deepEqual( $("#v2-i5").rules(), {});
delete $.validator.methods.customMethod1;
delete $.validator.messages.customMethod1;
@@ -220,35 +220,35 @@ test("rules(), add and remove static rules", function() {
firstname: "required date"
}
});
- same( $("#firstnamec").rules(), { required: true, date: true } );
+ deepEqual( $("#firstnamec").rules(), { required: true, date: true } );
$("#firstnamec").rules("remove", "date")
- same( $("#firstnamec").rules(), { required: true } );
+ deepEqual( $("#firstnamec").rules(), { required: true } );
$("#firstnamec").rules("add", "email");
- same( $("#firstnamec").rules(), { required: true, email: true } );
+ deepEqual( $("#firstnamec").rules(), { required: true, email: true } );
$("#firstnamec").rules("remove", "required");
- same( $("#firstnamec").rules(), { email: true } );
+ deepEqual( $("#firstnamec").rules(), { email: true } );
- same( $("#firstnamec").rules("remove"), { email: true } );
- same( $("#firstnamec").rules(), { } );
+ deepEqual( $("#firstnamec").rules("remove"), { email: true } );
+ deepEqual( $("#firstnamec").rules(), { } );
$("#firstnamec").rules("add", "required email");
- same( $("#firstnamec").rules(), { required: true, email: true } );
+ deepEqual( $("#firstnamec").rules(), { required: true, email: true } );
- same( $("#lastnamec").rules(), {} );
+ deepEqual( $("#lastnamec").rules(), {} );
$("#lastnamec").rules("add", "required");
$("#lastnamec").rules("add", {
minlength: 2
});
- same( $("#lastnamec").rules(), { required: true, minlength: 2 } );
+ deepEqual( $("#lastnamec").rules(), { required: true, minlength: 2 } );
var removedRules = $("#lastnamec").rules("remove", "required email");
- same( $("#lastnamec").rules(), { minlength: 2 } );
+ deepEqual( $("#lastnamec").rules(), { minlength: 2 } );
$("#lastnamec").rules("add", removedRules);
- same( $("#lastnamec").rules(), { required: true, minlength: 2 } );
+ deepEqual( $("#lastnamec").rules(), { required: true, minlength: 2 } );
});
test("rules(), add messages", function() {
@@ -260,7 +260,7 @@ test("rules(), add messages", function() {
});
$("#testForm1clean").valid();
$("#firstnamec").valid();
- same( v.settings.messages.firstname, undefined );
+ deepEqual( v.settings.messages.firstname, undefined );
$("#firstnamec").rules("add", {
messages: {
@@ -269,5 +269,5 @@ test("rules(), add messages", function() {
});
$("#firstnamec").valid();
- same( v.errorList[0] && v.errorList[0].message, "required" );
+ deepEqual( v.errorList[0] && v.errorList[0].message, "required" );
});
View
236 test/test.js
@@ -28,8 +28,8 @@ module("validator");
test("Constructor", function() {
var v1 = $("#testForm1").validate();
var v2 = $("#testForm1").validate();
- equals( v1, v2, "Calling validate() multiple times must return the same validator instance" );
- equals( v1.elements().length, 3, "validator elements" );
+ equal( v1, v2, "Calling validate() multiple times must return the same validator instance" );
+ equal( v1.elements().length, 3, "validator elements" );
});
test("validate() without elements, with non-form elements", function() {
@@ -96,8 +96,8 @@ test("addMethod2", function() {
var rule = $.validator.methods.complicatedPassword,
e = $('#text1')[0];
e.value = "";
- ok( v.element(e) === undefined, "Rule is optional, valid" );
- equals( 0, v.size() );
+ strictEqual( v.element(e), true, "Rule is optional, valid" );
+ equal( 0, v.size() );
e.value = "ko";
ok( !v.element(e), "Invalid, doesn't contain one of the required characters" );
e.value = "ko1";
@@ -131,14 +131,14 @@ test("form(): radio buttons: required", function () {
var v = $(form).validate({ rules: { testForm10Radio: "required"} });
ok(!v.form(), 'Invalid Form');
- equals($('#testForm10Radio1').attr('class'), 'error');
- equals($('#testForm10Radio2').attr('class'), 'error');
+ equal($('#testForm10Radio1').attr('class'), 'error');
+ equal($('#testForm10Radio2').attr('class'), 'error');
$('#testForm10Radio2').attr("checked", true);
ok(v.form(), 'Valid form');
- equals($('#testForm10Radio1').attr('class'), 'valid');
- equals($('#testForm10Radio2').attr('class'), 'valid');
+ equal($('#testForm10Radio1').attr('class'), 'valid');
+ equal($('#testForm10Radio2').attr('class'), 'valid');
});
test("form(): selects: min/required", function() {
@@ -251,8 +251,8 @@ test("submitHandler keeps submitting button", function() {
submitHandler: function(form) {
// dunno how to test this better; this tests the implementation that uses a hidden input
var hidden = $(form).find("input:hidden")[0];
- same(hidden.value, button.value)
- same(hidden.name, button.name)
+ deepEqual(hidden.value, button.value)
+ deepEqual(hidden.name, button.name)
}
});
$("#username").val("bla");
@@ -267,10 +267,10 @@ test("showErrors()", function() {
var element = $('#firstname')[0];
var v = $('#testForm1').validate();
ok( errorLabel.is(":hidden") );
- equals( 0, $("label.error[for=lastname]").size() );
+ equal( 0, $("label.error[for=lastname]").size() );
v.showErrors({"firstname": "required", "lastname": "bla"});
- equals( true, errorLabel.is(":visible") );
- equals( true, $("label.error[for=lastname]").is(":visible") );
+ equal( true, errorLabel.is(":visible") );
+ equal( true, $("label.error[for=lastname]").is(":visible") );
});
test("showErrors(), allow empty string and null as default message", function() {
@@ -289,11 +289,11 @@ test("showErrors(), allow empty string and null as default message", function()
}
});
ok( !$("#username").valid() );
- equals( "", $("label.error[for=username]").text() );
+ equal( "", $("label.error[for=username]").text() );
$("#username").val("ab");
ok( !$("#username").valid() );
- equals( "too short", $("label.error[for=username]").text() );
+ equal( "too short", $("label.error[for=username]").text() );
$("#username").val("abc");
ok( $("#username").valid() );
@@ -306,8 +306,8 @@ test("showErrors() - external messages", function() {
var messages = $.extend({}, $.validator.messages);
$.validator.addMethod("foo", function() { return false; });
$.validator.addMethod("bar", function() { return false; });
- equals( 0, $("#testForm4 label.error[for=f1]").size() );
- equals( 0, $("#testForm4 label.error[for=f2]").size() );
+ equal( 0, $("#testForm4 label.error[for=f1]").size() );
+ equal( 0, $("#testForm4 label.error[for=f2]").size() );
var form = $('#testForm4')[0];
var v = $(form).validate({
messages: {
@@ -316,8 +316,8 @@ test("showErrors() - external messages", function() {
}
});
v.form();
- equals( $("#testForm4 label.error[for=f1]").text(), "Please!" );
- equals( $("#testForm4 label.error[for=f2]").text(), "Wohoo!" );
+ equal( $("#testForm4 label.error[for=f1]").text(), "Please!" );
+ equal( $("#testForm4 label.error[for=f2]").text(), "Wohoo!" );
$.validator.methods = methods;
$.validator.messages = messages;
@@ -327,11 +327,11 @@ test("showErrors() - custom handler", function() {
expect(5);
var v = $('#testForm1').validate({
showErrors: function(errorMap, errorList) {
- equals( v, this );
- equals( v.errorList, errorList );
- equals( v.errorMap, errorMap );
- equals( "buga", errorMap.firstname );
- equals( "buga", errorMap.lastname );
+ equal( v, this );
+ equal( v.errorList, errorList );
+ equal( v.errorMap, errorMap );
+ equal( "buga", errorMap.firstname );
+ equal( "buga", errorMap.lastname );
}
});
v.form();
@@ -368,11 +368,11 @@ test("option: (un)highlight, custom", function() {
expect(5);
$("#testForm1clean").validate({
highlight: function(element, errorClass) {
- equals( "invalid", errorClass );
+ equal( "invalid", errorClass );
$(element).hide();
},
unhighlight: function(element, errorClass) {
- equals( "invalid", errorClass )
+ equal( "invalid", errorClass )
$(element).show();
},
errorClass: "invalid",
@@ -462,7 +462,7 @@ test("elements() order", function() {
test("defaultMessage(), empty title is ignored", function() {
var v = $("#userForm").validate();
- equals( "This field is required.", v.defaultMessage($("#username")[0], "required") );
+ equal( "This field is required.", v.defaultMessage($("#username")[0], "required") );
});
test("formatAndAdd", function() {
@@ -470,14 +470,14 @@ test("formatAndAdd", function() {
var v = $("#form").validate();
var fakeElement = { form: $("#form")[0], name: "bar" };
v.formatAndAdd(fakeElement, {method: "maxlength", parameters: 2})
- equals( "Please enter no more than 2 characters.", v.errorList[0].message );
- equals( "bar", v.errorList[0].element.name );
+ equal( "Please enter no more than 2 characters.", v.errorList[0].message );
+ equal( "bar", v.errorList[0].element.name );
v.formatAndAdd(fakeElement, {method: "range", parameters:[2,4]})
- equals( "Please enter a value between 2 and 4.", v.errorList[1].message );
+ equal( "Please enter a value between 2 and 4.", v.errorList[1].message );
v.formatAndAdd(fakeElement, {method: "range", parameters:[0,4]})
- equals( "Please enter a value between 0 and 4.", v.errorList[2].message );
+ equal( "Please enter a value between 0 and 4.", v.errorList[2].message );
});
test("formatAndAdd2", function() {
@@ -485,12 +485,12 @@ test("formatAndAdd2", function() {
var v = $("#form").validate();
var fakeElement = { form: $("#form")[0], name: "bar" };
jQuery.validator.messages.test1 = function(param, element) {
- equals( v, this );
- equals( 0, param );
+ equal( v, this );
+ equal( 0, param );
return "element " + element.name + " is not valid";
};
v.formatAndAdd(fakeElement, {method: "test1", parameters: 0})
- equals( "element bar is not valid", v.errorList[0].message );
+ equal( "element bar is not valid", v.errorList[0].message );
});
test("formatAndAdd, auto detect substitution string", function() {
@@ -509,7 +509,7 @@ test("formatAndAdd, auto detect substitution string", function() {
});
$("#firstnamec").val("abc");
v.form();
- equals( "at least 5, up to 10", v.errorList[0].message );
+ equal( "at least 5, up to 10", v.errorList[0].message );
})
test("error containers, simple", function() {
@@ -525,24 +525,24 @@ test("error containers, simple", function() {
v.prepareForm();
ok( v.valid(), "form is valid" );
- equals( 0, container.find("label").length, "There should be no error labels" );
- equals( "", container.find("h3").html() );
+ equal( 0, container.find("label").length, "There should be no error labels" );
+ equal( "", container.find("h3").html() );
v.prepareForm();
v.errorList = [{message:"bar", element: {name:"foo"}}, {message: "necessary", element: {name:"required"}}];
ok( !v.valid(), "form is not valid after adding errors manually" );
v.showErrors();
- equals( container.find("label").length, 2, "There should be two error labels" );
+ equal( container.find("label").length, 2, "There should be two error labels" );
ok( container.is(":visible"), "Check that the container is visible" );
container.find("label").each(function() {
ok( $(this).is(":visible"), "Check that each label is visible" );
});
- equals( "There are 2 errors in your form.", container.find("h3").html() );
+ equal( "There are 2 errors in your form.", container.find("h3").html() );
v.prepareForm();
ok( v.valid(), "form is valid after a reset" );
v.showErrors();
- equals( container.find("label").length, 2, "There should still be two error labels" );
+ equal( container.find("label").length, 2, "There should still be two error labels" );
ok( container.is(":hidden"), "Check that the container is hidden" );
container.find("label").each(function() {
ok( $(this).is(":hidden"), "Check that each label is hidden" );
@@ -560,21 +560,21 @@ test("error containers, with labelcontainer I", function() {
});
ok( v.valid(), "form is valid" );
- equals( 0, container.find("label").length, "There should be no error labels in the container" );
- equals( 0, labelcontainer.find("label").length, "There should be no error labels in the labelcontainer" );
- equals( 0, labelcontainer.find("li").length, "There should be no lis labels in the labelcontainer" );
+ equal( 0, container.find("label").length, "There should be no error labels in the container" );
+ equal( 0, labelcontainer.find("label").length, "There should be no error labels in the labelcontainer" );
+ equal( 0, labelcontainer.find("li").length, "There should be no lis labels in the labelcontainer" );
v.errorList = [{message:"bar", element: {name:"foo"}}, {name: "required", message: "necessary", element: {name:"required"}}];
ok( !v.valid(), "form is not valid after adding errors manually" );
v.showErrors();
- equals( 0, container.find("label").length, "There should be no error label in the container" );
- equals( 2, labelcontainer.find("label").length, "There should be two error labels in the labelcontainer" );
- equals( 2, labelcontainer.find("li").length, "There should be two error lis in the labelcontainer" );
+ equal( 0, container.find("label").length, "There should be no error label in the container" );
+ equal( 2, labelcontainer.find("label").length, "There should be two error labels in the labelcontainer" );
+ equal( 2, labelcontainer.find("li").length, "There should be two error lis in the labelcontainer" );
ok( container.is(":visible"), "Check that the container is visible" );
ok( labelcontainer.is(":visible"), "Check that the labelcontainer is visible" );
var labels = labelcontainer.find("label").each(function() {
ok( $(this).is(":visible"), "Check that each label is visible1" );
- equals( "li", $(this).parent()[0].tagName.toLowerCase(), "Check that each label is wrapped in an li" );
+ equal( "li", $(this).parent()[0].tagName.toLowerCase(), "Check that each label is wrapped in an li" );
ok( $(this).parent("li").is(":visible"), "Check that each parent li is visible" );
});
});
@@ -594,20 +594,20 @@ test("errorcontainer, show/hide only on submit", function() {
this.defaultShowErrors();
}
});
- equals( "", container.html(), "must be empty" );
- equals( "", labelContainer.html(), "must be empty" );
+ equal( "", container.html(), "must be empty" );
+ equal( "", labelContainer.html(), "must be empty" );
// validate whole form, both showErrors and invalidHandler must be called once
// preferably invalidHandler first, showErrors second
ok( !v.form(), "invalid form" );
- equals( 2, labelContainer.find("label").length );
- equals( "There are 2 errors in your form.", container.html() );
+ equal( 2, labelContainer.find("label").length );
+ equal( "There are 2 errors in your form.", container.html() );
ok( labelContainer.is(":visible"), "must be visible" );
ok( container.is(":visible"), "must be visible" );
$("#firstname").val("hix").keyup();
$("#testForm1").triggerHandler("keyup", [jQuery.event.fix({ type: "keyup", target: $("#firstname")[0] })]);
- equals( 1, labelContainer.find("label:visible").length );
- equals( "There are 1 errors in your form.", container.html() );
+ equal( 1, labelContainer.find("label:visible").length );
+ equal( "There are 1 errors in your form.", container.html() );
$("#lastname").val("abc");
ok( v.form(), "Form now valid, trigger showErrors but not invalid-form" );
@@ -635,7 +635,7 @@ test("focusInvalid()", function() {
// TODO when using 1.4 focusin, triggered twice; fix once not testing against 1.3 anymore
// expect(1);
var inputs = $("#testForm1 input").focus(function() {
- equals( inputs[0], this, "focused first element" );
+ equal( inputs[0], this, "focused first element" );
});
var v = $("#testForm1").validate();
v.form();
@@ -648,9 +648,9 @@ test("findLastActive()", function() {
ok( !v.findLastActive() );
v.form();
v.focusInvalid();
- equals( v.findLastActive(), $("#firstname")[0] );
+ equal( v.findLastActive(), $("#firstname")[0] );
var lastActive = $("#lastname").trigger("focus").trigger("focusin")[0];
- equals( v.lastActive, lastActive );
+ equal( v.lastActive, lastActive );
});
test("validating multiple checkboxes with 'required'", function() {
@@ -675,7 +675,7 @@ test("dynamic form", function() {
$("<input class='{required:true}' name='list" + counter++ + "' />").appendTo("#testForm2");
}
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
var v = $("#testForm2").validate();
v.form();
@@ -706,15 +706,15 @@ test("dynamic form", function() {
test("idOrName()", function() {
expect(4);
var v = $("#testForm1").validate();
- equals( "form8input", v.idOrName( $("#form8input")[0] ) );
- equals( "check", v.idOrName( $("#form6check1")[0] ) );
- equals( "agree", v.idOrName( $("#agb")[0] ) );
- equals( "button", v.idOrName( $("#form :button")[0] ) );
+ equal( "form8input", v.idOrName( $("#form8input")[0] ) );
+ equal( "check", v.idOrName( $("#form6check1")[0] ) );
+ equal( "agree", v.idOrName( $("#agb")[0] ) );
+ equal( "button", v.idOrName( $("#form :button")[0] ) );
});
test("resetForm()", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
var v = $("#testForm1").validate();
v.form();
@@ -722,19 +722,19 @@ test("resetForm()", function() {
$("#firstname").val("hiy");
v.resetForm();
errors(0);
- equals("", $("#firstname").val(), "form plugin is included, therefor resetForm must also reset inputs, not only errors");
+ equal("", $("#firstname").val(), "form plugin is included, therefor resetForm must also reset inputs, not only errors");
});
test("message from title", function() {
var v = $("#withTitle").validate();
v.checkForm();
- equals(v.errorList[0].message, "fromtitle", "title not used");
+ equal(v.errorList[0].message, "fromtitle", "title not used");
});
test("ignoreTitle", function() {
var v = $("#withTitle").validate({ignoreTitle:true});
v.checkForm();
- equals(v.errorList[0].message, $.validator.messages["required"], "title used when it should have been ignored");
+ equal(v.errorList[0].message, $.validator.messages["required"], "title used when it should have been ignored");
});
test("ajaxSubmit", function() {
@@ -746,7 +746,7 @@ test("ajaxSubmit", function() {
submitHandler: function(form) {
jQuery(form).ajaxSubmit({
success: function(response) {
- equals("Hi Peter, welcome back.", response);
+ equal("Hi Peter, welcome back.", response);
start();
}
});
@@ -760,7 +760,7 @@ module("misc");
test("success option", function() {
expect(7);
- equals( "", $("#firstname").val() );
+ equal( "", $("#firstname").val() );
var v = $("#testForm1").validate({
success: "valid"
});
@@ -778,7 +778,7 @@ test("success option", function() {
test("success option2", function() {
expect(5);
- equals( "", $("#firstname").val() );
+ equal( "", $("#firstname").val() );
var v = $("#testForm1").validate({
success: "valid"
});
@@ -793,16 +793,16 @@ test("success option2", function() {
test("success option3", function() {
expect(5);
- equals( "", $("#firstname").val() );
+ equal( "", $("#firstname").val() );
$("#errorFirstname").remove();
var v = $("#testForm1").validate({
success: "valid"
});
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
$("#firstname").val("hi");
v.form();
var labels = $("#testForm1 label");
- equals( 3, labels.size() );
+ equal( 3, labels.size() );
ok( labels.eq(0).is(".valid") );
ok( !labels.eq(1).is(".valid") );
});
@@ -810,12 +810,12 @@ test("success option3", function() {
test("successlist", function() {
var v = $("#form").validate({ success: "xyz" });
v.form();
- equals(0, v.successList.length);
+ equal(0, v.successList.length);
});
test("success isn't called for optional elements", function() {
expect(4);
- equals( "", $("#firstname").removeClass().val() );
+ equal( "", $("#firstname").removeClass().val() );
$("#something").remove();
$("#lastname").remove();
$("#errorFirstname").remove();
@@ -827,16 +827,16 @@ test("success isn't called for optional elements", function() {
firstname: "email"
}
});
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
v.form();
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
$("#firstname").valid();
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
});
test("all rules are evaluated even if one returns a dependency-mistmatch", function() {
expect(6);
- equals( "", $("#firstname").removeClass().val() );
+ equal( "", $("#firstname").removeClass().val() );
$("#lastname").remove();
$("#errorFirstname").remove();
$.validator.addMethod("custom1", function() {
@@ -848,11 +848,11 @@ test("all rules are evaluated even if one returns a dependency-mistmatch", funct
firstname: {email:true, custom1: true}
}
});
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
v.form();
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
$("#firstname").valid();
- equals( 0, $("#testForm1 label").size() );
+ equal( 0, $("#testForm1 label").size() );
delete $.validator.methods.custom1;
delete $.validator.messages.custom1;
@@ -860,21 +860,21 @@ test("all rules are evaluated even if one returns a dependency-mistmatch", funct
test("messages", function() {
var m = jQuery.validator.messages;
- equals( "Please enter no more than 0 characters.", m.maxlength(0) );
- equals( "Please enter at least 1 characters.", m.minlength(1) );
- equals( "Please enter a value between 1 and 2 characters long.", m.rangelength([1, 2]) );
- equals( "Please enter a value less than or equal to 1.", m.max(1) );
- equals( "Please enter a value greater than or equal to 0.", m.min(0) );
- equals( "Please enter a value between 1 and 2.", m.range([1, 2]) );
+ equal( "Please enter no more than 0 characters.", m.maxlength(0) );
+ equal( "Please enter at least 1 characters.", m.minlength(1) );
+ equal( "Please enter a value between 1 and 2 characters long.", m.rangelength([1, 2]) );
+ equal( "Please enter a value less than or equal to 1.", m.max(1) );
+ equal( "Please enter a value greater than or equal to 0.", m.min(0) );
+ equal( "Please enter a value between 1 and 2.", m.range([1, 2]) );
});
test("jQuery.validator.format", function() {
- equals( "Please enter a value between 0 and 1.", jQuery.validator.format("Please enter a value between {0} and {1}.", 0, 1) );
- equals( "0 is too fast! Enter a value smaller then 0 and at least -15", jQuery.validator.format("{0} is too fast! Enter a value smaller then {0} and at least {1}", 0, -15) );
+ equal( "Please enter a value between 0 and 1.", jQuery.validator.format("Please enter a value between {0} and {1}.", 0, 1) );
+ equal( "0 is too fast! Enter a value smaller then 0 and at least -15", jQuery.validator.format("{0} is too fast! Enter a value smaller then {0} and at least {1}", 0, -15) );
var template = jQuery.validator.format("{0} is too fast! Enter a value smaller then {0} and at least {1}");
- equals( "0 is too fast! Enter a value smaller then 0 and at least -15", template(0, -15) );
+ equal( "0 is too fast! Enter a value smaller then 0 and at least -15", template(0, -15) );
template = jQuery.validator.format("Please enter a value between {0} and {1}.");
- equals( "Please enter a value between 1 and 2.", template([1, 2]) );
+ equal( "Please enter a value between 1 and 2.", template([1, 2]) );
});
test("option: ignore", function() {
@@ -882,7 +882,7 @@ test("option: ignore", function() {
ignore: "[name=lastname]"
});
v.form();
- equals( 1, v.size() );
+ equal( 1, v.size() );
});
test("option: subformRequired", function() {
@@ -893,10 +893,10 @@ test("option: subformRequired", function() {
}, "");
var v = $("#subformRequired").validate();
v.form();
- equals( 1, v.size() );
+ equal( 1, v.size() );
$("#bill_to_co").attr("checked", false);
v.form();
- equals( 2, v.size() );
+ equal( 2, v.size() );
delete $.validator.methods.billingRequired;
delete $.validator.messages.billingRequired;
@@ -906,43 +906,43 @@ module("expressions");
test("expression: :blank", function() {
var e = $("#lastname")[0];
- equals( 1, $(e).filter(":blank").length );
+ equal( 1, $(e).filter(":blank").length );
e.value = " ";
- equals( 1, $(e).filter(":blank").length );
+ equal( 1, $(e).filter(":blank").length );
e.value = " "
- equals( 1, $(e).filter(":blank").length );
+ equal( 1, $(e).filter(":blank").length );
e.value= " a ";
- equals( 0, $(e).filter(":blank").length );
+ equal( 0, $(e).filter(":blank").length );
});
test("expression: :filled", function() {
var e = $("#lastname")[0];
- equals( 0, $(e).filter(":filled").length );
+ equal( 0, $(e).filter(":filled").length );
e.value = " ";
- equals( 0, $(e).filter(":filled").length );
+ equal( 0, $(e).filter(":filled").length );
e.value = " "
- equals( 0, $(e).filter(":filled").length );
+ equal( 0, $(e).filter(":filled").length );
e.value= " a ";
- equals( 1, $(e).filter(":filled").length );
+ equal( 1, $(e).filter(":filled").length );
});
test("expression: :unchecked", function() {
var e = $("#check2")[0];
- equals( 1, $(e).filter(":unchecked").length );
+ equal( 1, $(e).filter(":unchecked").length );
e.checked = true;
- equals( 0, $(e).filter(":unchecked").length );
+ equal( 0, $(e).filter(":unchecked").length );
e.checked = false;
- equals( 1, $(e).filter(":unchecked").length );
+ equal( 1, $(e).filter(":unchecked").length );
});
module("events");
test("validate on blur", function() {
function errors(expected, message) {
- equals(v.size(), expected, message );
+ equal(v.size(), expected, message );
}
function labels(expected) {
- equals(v.errors().filter(":visible").size(), expected);
+ equal(v.errors().filter(":visible").size(), expected);
}
function blur(target) {
target.trigger("blur").trigger("focusout");
@@ -981,7 +981,7 @@ test("validate on blur", function() {
test("validate on keyup", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
function keyup(target) {
target.trigger("keyup");
@@ -1011,7 +1011,7 @@ test("validate on keyup", function() {
test("validate on not keyup, only blur", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
var e = $("#firstname");
var v = $("#testForm1").validate({
@@ -1028,7 +1028,7 @@ test("validate on not keyup, only blur", function() {
test("validate on keyup and blur", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
var e = $("#firstname");
var v = $("#testForm1").validate();
@@ -1042,7 +1042,7 @@ test("validate on keyup and blur", function() {
test("validate email on keyup and blur", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
var e = $("#firstname");
var v = $("#testForm1").validate();
@@ -1058,7 +1058,7 @@ test("validate email on keyup and blur", function() {
test("validate checkbox on click", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
function trigger(element) {
element.click();
@@ -1074,7 +1074,7 @@ test("validate checkbox on click", function() {
trigger(e);
errors(0);
trigger(e);
- equals( false, v.form() );
+ equal( false, v.form() );
errors(1);
trigger(e);
errors(0);
@@ -1084,7 +1084,7 @@ test("validate checkbox on click", function() {
test("validate multiple checkbox on click", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
function trigger(element) {
element.click();
@@ -1105,7 +1105,7 @@ test("validate multiple checkbox on click", function() {
trigger(e2);
errors(0);
trigger(e2);
- equals( false, v.form() );
+ equal( false, v.form() );
errors(1);
trigger(e2);
errors(0);
@@ -1129,15 +1129,15 @@ test("correct checkbox receives the error", function(){
}
}
});
- equals(false, v.form());
+ equal(false, v.form());
trigger(e1);
- equals(false, v.form());
+ equal(false, v.form());
ok(v.errorList[0].element.id === v.currentElements[0].id, "the proper checkbox has the error AND is present in currentElements");
});
test("validate radio on click", function() {
function errors(expected, message) {
- equals(expected, v.size(), message );
+ equal(expected, v.size(), message );
}
function trigger(element) {
element.click();
@@ -1152,7 +1152,7 @@ test("validate radio on click", function() {
}
});
errors(0);
- equals( false, v.form() );
+ equal( false, v.form() );
errors(1);
trigger(e2);
errors(0);
Please sign in to comment.
Something went wrong with that request. Please try again.