Fix whitespace and formatting in additional-methods and tests

This commit is contained in:
Jörn Zaefferer
2012-04-03 16:24:45 +02:00
parent 78a739f7c5
commit 8f8792fd86
3 changed files with 204 additions and 211 deletions

View File

@@ -231,7 +231,7 @@ test("required", function() {
test("required with dependencies", function() {
var v = jQuery("#form").validate(),
method = $.validator.methods.required,
e = $('#hidden2, #select1, #area2, #radio1, #check2');
e = $('#hidden2, #select1, #area2, #radio1, #check2');
ok( method.call( v, e[0].value, e[0], "asffsaa"), "Valid text input due to depencie not met" );
ok(!method.call( v, e[0].value, e[0], "input"), "Invalid text input" );
ok( method.call( v, e[0].value, e[0], function() { return false; }), "Valid text input due to depencie not met" );
@@ -608,43 +608,41 @@ test('creditcardtypes, mastercard', function() {
});
function fillFormWithValuesAndExpect(formSelector, inputValues, expected) {
for(i=0; i < inputValues.length; i++) {
$(formSelector + ' input:eq(' + i + ')').val(inputValues[i]);
}
var actual = $(formSelector).valid();
equals(actual, expected, $.format("Filled inputs of form '{0}' with {1} values ({2})", formSelector, inputValues.length, inputValues.toString()));
for (i=0; i < inputValues.length; i++) {
$(formSelector + ' input:eq(' + i + ')').val(inputValues[i]);
}
var actual = $(formSelector).valid();
equals(actual, expected, $.format("Filled inputs of form '{0}' with {1} values ({2})", formSelector, inputValues.length, inputValues.toString()));
}
test('require_from_group', function() {
$("#productInfo").validate({
rules: {
partnumber: {require_from_group: [2,".productInfo"]},
description: {require_from_group: [2,".productInfo"]}
}
});
fillFormWithValuesAndExpect('#productInfo', [], false);
fillFormWithValuesAndExpect('#productInfo', [123], false);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget'], true);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget', 'red'], true);
$("#productInfo").validate({
rules: {
partnumber: {require_from_group: [2,".productInfo"]},
description: {require_from_group: [2,".productInfo"]}
}
});
fillFormWithValuesAndExpect('#productInfo', [], false);
fillFormWithValuesAndExpect('#productInfo', [123], false);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget'], true);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget', 'red'], true);
});
test('skip_or_fill_minimum', function() {
$("#productInfo").validate({
rules: {
partnumber: {skip_or_fill_minimum: [2,".productInfo"]},
description: {skip_or_fill_minimum: [2,".productInfo"]},
color: {skip_or_fill_minimum: [2,".productInfo"]}
}
});
fillFormWithValuesAndExpect('#productInfo', [], true);
fillFormWithValuesAndExpect('#productInfo', [123], false);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget'], true);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget', 'red'], true);
$("#productInfo").validate({
rules: {
partnumber: {skip_or_fill_minimum: [2,".productInfo"]},
description: {skip_or_fill_minimum: [2,".productInfo"]},
color: {skip_or_fill_minimum: [2,".productInfo"]}
}
});
fillFormWithValuesAndExpect('#productInfo', [], true);
fillFormWithValuesAndExpect('#productInfo', [123], false);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget'], true);
fillFormWithValuesAndExpect('#productInfo', [123, 'widget', 'red'], true);
});
})(jQuery);