aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/validate/tests
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dojox/validate/tests')
-rw-r--r--includes/js/dojox/validate/tests/creditcard.js119
-rw-r--r--includes/js/dojox/validate/tests/module.js14
-rw-r--r--includes/js/dojox/validate/tests/runTests.html9
-rw-r--r--includes/js/dojox/validate/tests/validate.js316
4 files changed, 458 insertions, 0 deletions
diff --git a/includes/js/dojox/validate/tests/creditcard.js b/includes/js/dojox/validate/tests/creditcard.js
new file mode 100644
index 0000000..bacb01e
--- /dev/null
+++ b/includes/js/dojox/validate/tests/creditcard.js
@@ -0,0 +1,119 @@
+if(!dojo._hasResource["dojox.validate.tests.creditcard"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.validate.tests.creditcard"] = true;
+dojo.provide("dojox.validate.tests.creditcard");
+dojo.require("dojox.validate.creditCard");
+
+tests.register("dojox.validate.tests.creditcard",
+ [{
+ name:"isValidLuhn",
+ runTests: function(tests) {
+ tests.t(dojox.validate.isValidLuhn('5105105105105100')); //test string input
+ tests.t(dojox.validate.isValidLuhn('5105-1051 0510-5100')); //test string input with dashes and spaces (commonly used when entering card #'s)
+ tests.t(dojox.validate.isValidLuhn(38520000023237)); //test numerical input as well
+ tests.f(dojox.validate.isValidLuhn(3852000002323)); //testing failures
+ tests.t(dojox.validate.isValidLuhn(18)); //length doesnt matter
+ tests.f(dojox.validate.isValidLuhn(818181)); //short length failure
+ }
+ },
+ {
+ name:"isValidCvv",
+ runTests: function(tests) {
+ tests.t(dojox.validate.isValidCvv('123','mc')); //string is ok
+ tests.f(dojox.validate.isValidCvv('5AA','ec')); //invalid characters are not ok
+ tests.t(dojox.validate.isValidCvv(723,'mc')); //numbers are ok too
+ tests.f(dojox.validate.isValidCvv(7234,'mc')); //too long
+ tests.t(dojox.validate.isValidCvv(612,'ec'));
+ tests.t(dojox.validate.isValidCvv(421,'vi'));
+ tests.t(dojox.validate.isValidCvv(543,'di'));
+ tests.t(dojox.validate.isValidCvv('1234','ax'));
+ tests.t(dojox.validate.isValidCvv(4321,'ax'));
+ tests.f(dojox.validate.isValidCvv(43215,'ax')); //too long
+ tests.f(dojox.validate.isValidCvv(215,'ax')); //too short
+ }
+ },
+ {
+ name:"isValidCreditCard",
+ runTests: function(tests) {
+ //misc checks
+ tests.t(dojox.validate.isValidCreditCard('5105105105105100','mc')); //test string input
+ tests.t(dojox.validate.isValidCreditCard('5105-1051 0510-5100','mc')); //test string input with dashes and spaces (commonly used when entering card #'s)
+ tests.t(dojox.validate.isValidCreditCard(5105105105105100,'mc')); //test numerical input as well
+ tests.f(dojox.validate.isValidCreditCard('5105105105105100','vi')); //fails, wrong card type
+ //Mastercard/Eurocard checks
+ tests.t(dojox.validate.isValidCreditCard('5105105105105100','mc'));
+ tests.t(dojox.validate.isValidCreditCard('5204105105105100','ec'));
+ tests.t(dojox.validate.isValidCreditCard('5303105105105100','mc'));
+ tests.t(dojox.validate.isValidCreditCard('5402105105105100','ec'));
+ tests.t(dojox.validate.isValidCreditCard('5501105105105100','mc'));
+ //Visa card checks
+ tests.t(dojox.validate.isValidCreditCard('4111111111111111','vi'));
+ tests.t(dojox.validate.isValidCreditCard('4111111111010','vi'));
+ //American Express card checks
+ tests.t(dojox.validate.isValidCreditCard('378 2822 4631 0005','ax'));
+ tests.t(dojox.validate.isValidCreditCard('341-1111-1111-1111','ax'));
+ //Diners Club/Carte Blanch card checks
+ tests.t(dojox.validate.isValidCreditCard('36400000000000','dc'));
+ tests.t(dojox.validate.isValidCreditCard('38520000023237','bl'));
+ tests.t(dojox.validate.isValidCreditCard('30009009025904','dc'));
+ tests.t(dojox.validate.isValidCreditCard('30108009025904','bl'));
+ tests.t(dojox.validate.isValidCreditCard('30207009025904','dc'));
+ tests.t(dojox.validate.isValidCreditCard('30306009025904','bl'));
+ tests.t(dojox.validate.isValidCreditCard('30405009025904','dc'));
+ tests.t(dojox.validate.isValidCreditCard('30504009025904','bl'));
+ //Discover card checks
+ tests.t(dojox.validate.isValidCreditCard('6011111111111117','di'));
+ //JCB card checks
+ tests.t(dojox.validate.isValidCreditCard('3530111333300000','jcb'));
+ tests.t(dojox.validate.isValidCreditCard('213100000000001','jcb'));
+ tests.t(dojox.validate.isValidCreditCard('180000000000002','jcb'));
+ tests.f(dojox.validate.isValidCreditCard('1800000000000002','jcb')); //should fail, good checksum, good prefix, but wrong length'
+ //Enroute card checks
+ tests.t(dojox.validate.isValidCreditCard('201400000000000','er'));
+ tests.t(dojox.validate.isValidCreditCard('214900000000000','er'));
+ }
+ },
+ {
+ name:"isValidCreditCardNumber",
+ runTests: function(tests) {
+ //misc checks
+ tests.t(dojox.validate.isValidCreditCardNumber('5105105105105100','mc')); //test string input
+ tests.t(dojox.validate.isValidCreditCardNumber('5105-1051 0510-5100','mc')); //test string input with dashes and spaces (commonly used when entering card #'s)
+ tests.t(dojox.validate.isValidCreditCardNumber(5105105105105100,'mc')); //test numerical input as well
+ tests.f(dojox.validate.isValidCreditCardNumber('5105105105105100','vi')); //fails, wrong card type
+ //Mastercard/Eurocard checks
+ tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5100000000000000')); //should match 'mc|ec'
+ tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5200000000000000')); //should match 'mc|ec'
+ tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5300000000000000')); //should match 'mc|ec'
+ tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5400000000000000')); //should match 'mc|ec'
+ tests.is("mc|ec", dojox.validate.isValidCreditCardNumber('5500000000000000')); //should match 'mc|ec'
+ tests.f(dojox.validate.isValidCreditCardNumber('55000000000000000')); //should fail, too long
+ //Visa card checks
+ tests.is("vi", dojox.validate.isValidCreditCardNumber('4111111111111111')); //should match 'vi'
+ tests.is("vi", dojox.validate.isValidCreditCardNumber('4111111111010')); //should match 'vi'
+ //American Express card checks
+ tests.is("ax", dojox.validate.isValidCreditCardNumber('378 2822 4631 0005')); //should match 'ax'
+ tests.is("ax", dojox.validate.isValidCreditCardNumber('341-1111-1111-1111')); //should match 'ax'
+ //Diners Club/Carte Blanch card checks
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('36400000000000')); //should match 'dc|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('38520000023237')); //should match 'dc|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30009009025904')); //should match 'di|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30108009025904')); //should match 'di|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30207009025904')); //should match 'di|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30306009025904')); //should match 'di|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30405009025904')); //should match 'di|bl'
+ tests.is("dc|bl", dojox.validate.isValidCreditCardNumber('30504009025904')); //should match 'di|bl'
+ //Discover card checks
+ tests.is("di", dojox.validate.isValidCreditCardNumber('6011111111111117')); //should match 'di'
+ //JCB card checks
+ tests.is("jcb", dojox.validate.isValidCreditCardNumber('3530111333300000')); //should match 'jcb'
+ tests.is("jcb", dojox.validate.isValidCreditCardNumber('213100000000001')); //should match 'jcb'
+ tests.is("jcb", dojox.validate.isValidCreditCardNumber('180000000000002')); //should match 'jcb'
+ tests.f(dojox.validate.isValidCreditCardNumber('1800000000000002')); //should fail, good checksum, good prefix, but wrong length'
+ //Enroute card checks
+ tests.is("er", dojox.validate.isValidCreditCardNumber('201400000000000')); //should match 'er'
+ tests.is("er", dojox.validate.isValidCreditCardNumber('214900000000000')); //should match 'er'
+ }
+ }
+]);
+
+}
diff --git a/includes/js/dojox/validate/tests/module.js b/includes/js/dojox/validate/tests/module.js
new file mode 100644
index 0000000..c04fe4f
--- /dev/null
+++ b/includes/js/dojox/validate/tests/module.js
@@ -0,0 +1,14 @@
+if(!dojo._hasResource["dojox.validate.tests.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.validate.tests.module"] = true;
+dojo.provide("dojox.validate.tests.module");
+
+try{
+ dojo.require("dojox.validate.tests.creditcard");
+ dojo.require("dojox.validate.tests.validate");
+
+}catch(e){
+ doh.debug(e);
+ console.debug(e);
+}
+
+}
diff --git a/includes/js/dojox/validate/tests/runTests.html b/includes/js/dojox/validate/tests/runTests.html
new file mode 100644
index 0000000..390674c
--- /dev/null
+++ b/includes/js/dojox/validate/tests/runTests.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Dijit Unit Test Runner</title>
+ <meta http-equiv="REFRESH" content="0;url=../../../util/doh/runner.html?testModule=dojox.validate.tests.module"></HEAD>
+ <BODY>
+ Redirecting to D.O.H runner.
+ </BODY>
+</HTML>
diff --git a/includes/js/dojox/validate/tests/validate.js b/includes/js/dojox/validate/tests/validate.js
new file mode 100644
index 0000000..2fb272f
--- /dev/null
+++ b/includes/js/dojox/validate/tests/validate.js
@@ -0,0 +1,316 @@
+if(!dojo._hasResource["dojox.validate.tests.validate"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.validate.tests.validate"] = true;
+dojo.provide("dojox.validate.tests.validate");
+
+dojo.require("dojox.validate._base");
+dojo.require("dojox.validate.check");
+dojo.require("dojox.validate.us");
+dojo.require("dojox.validate.ca");
+dojo.require("dojox.validate.web");
+dojo.require("dojox.validate.isbn");
+
+tests.register("dojox.validate.tests.validate",
+ [{
+ name: "isText",
+ runTest: function(tests){
+ tests.t(dojox.validate.isValidIsbn('0596007590')); //test string input
+ tests.t(dojox.validate.isValidIsbn('0-596-00759-0')); //test string input with dashes
+ tests.f(dojox.validate.isValidIsbn(596007590)); //test numerical input as well
+ tests.t(dojox.validate.isValidIsbn("960-425-059-0"));
+ tests.t(dojox.validate.isValidIsbn(9604250590)); //test numerical input as well
+ tests.t(dojox.validate.isValidIsbn('0-9752298-0-X')); // test string with X
+ tests.t(dojox.validate.isValidIsbn('0-9752298-0-x'));
+ tests.t(dojox.validate.isValidIsbn('097522980x'));
+ tests.t(dojox.validate.isValidIsbn('097522980X'));
+ tests.f(dojox.validate.isValidIsbn(596007598)); //testing failures
+ tests.f(dojox.validate.isValidIsbn('059-600759-X')); //testing failures
+ tests.f(dojox.validate.isValidIsbn('059600')); // too short
+
+ tests.t(dojox.validate.isValidIsbn('9780596007591'));
+ tests.t(dojox.validate.isValidIsbn('978-0-596 00759-1'));
+ tests.t(dojox.validate.isValidIsbn(9780596007591));
+ tests.f(dojox.validate.isValidIsbn('978059600759X'));
+ tests.f(dojox.validate.isValidIsbn('978-3250-596 00759-1 '));
+ tests.f(dojox.validate.isValidIsbn('3250-596 00759 '));
+
+ tests.t(dojox.validate.isText(' x'));
+ tests.t(dojox.validate.isText('x '));
+ tests.t(dojox.validate.isText(' x '));
+ tests.f(dojox.validate.isText(' '));
+ tests.f(dojox.validate.isText(''));
+
+ // test lengths
+ tests.t(dojox.validate.isText('123456', {length: 6} ));
+ tests.f(dojox.validate.isText('1234567', {length: 6} ));
+ tests.t(dojox.validate.isText('1234567', {minlength: 6} ));
+ tests.t(dojox.validate.isText('123456', {minlength: 6} ));
+ tests.f(dojox.validate.isText('12345', {minlength: 6} ));
+ tests.f(dojox.validate.isText('1234567', {maxlength: 6} ));
+ tests.t(dojox.validate.isText('123456', {maxlength: 6} ));
+ }
+ },
+ {
+ name: "isIpAddress",
+ runTest: function(tests){
+ tests.t(dojox.validate.isIpAddress('24.17.155.40'));
+ tests.f(dojox.validate.isIpAddress('024.17.155.040'));
+ tests.t(dojox.validate.isIpAddress('255.255.255.255'));
+ tests.f(dojox.validate.isIpAddress('256.255.255.255'));
+ tests.f(dojox.validate.isIpAddress('255.256.255.255'));
+ tests.f(dojox.validate.isIpAddress('255.255.256.255'));
+ tests.f(dojox.validate.isIpAddress('255.255.255.256'));
+
+ // test dotted hex
+ tests.t(dojox.validate.isIpAddress('0x18.0x11.0x9b.0x28'));
+ tests.f(dojox.validate.isIpAddress('0x18.0x11.0x9b.0x28', {allowDottedHex: false}) );
+ tests.t(dojox.validate.isIpAddress('0x18.0x000000011.0x9b.0x28'));
+ tests.t(dojox.validate.isIpAddress('0xff.0xff.0xff.0xff'));
+ tests.f(dojox.validate.isIpAddress('0x100.0xff.0xff.0xff'));
+
+ // test dotted octal
+ tests.t(dojox.validate.isIpAddress('0030.0021.0233.0050'));
+ tests.f(dojox.validate.isIpAddress('0030.0021.0233.0050', {allowDottedOctal: false}) );
+ tests.t(dojox.validate.isIpAddress('0030.0000021.0233.00000050'));
+ tests.t(dojox.validate.isIpAddress('0377.0377.0377.0377'));
+ tests.f(dojox.validate.isIpAddress('0400.0377.0377.0377'));
+ tests.f(dojox.validate.isIpAddress('0377.0378.0377.0377'));
+ tests.f(dojox.validate.isIpAddress('0377.0377.0380.0377'));
+ tests.f(dojox.validate.isIpAddress('0377.0377.0377.377'));
+
+ // test decimal
+ tests.t(dojox.validate.isIpAddress('3482223595'));
+ tests.t(dojox.validate.isIpAddress('0'));
+ tests.t(dojox.validate.isIpAddress('4294967295'));
+ tests.f(dojox.validate.isIpAddress('4294967296'));
+ tests.f(dojox.validate.isIpAddress('3482223595', {allowDecimal: false}));
+
+ // test hex
+ tests.t(dojox.validate.isIpAddress('0xCF8E83EB'));
+ tests.t(dojox.validate.isIpAddress('0x0'));
+ tests.t(dojox.validate.isIpAddress('0x00ffffffff'));
+ tests.f(dojox.validate.isIpAddress('0x100000000'));
+ tests.f(dojox.validate.isIpAddress('0xCF8E83EB', {allowHex: false}));
+
+ // IPv6
+ tests.t(dojox.validate.isIpAddress('fedc:BA98:7654:3210:FEDC:BA98:7654:3210'));
+ tests.t(dojox.validate.isIpAddress('1080:0:0:0:8:800:200C:417A'));
+ tests.f(dojox.validate.isIpAddress('1080:0:0:0:8:800:200C:417A', {allowIPv6: false}));
+
+ // Hybrid of IPv6 and IPv4
+ tests.t(dojox.validate.isIpAddress('0:0:0:0:0:0:13.1.68.3'));
+ tests.t(dojox.validate.isIpAddress('0:0:0:0:0:FFFF:129.144.52.38'));
+ tests.f(dojox.validate.isIpAddress('0:0:0:0:0:FFFF:129.144.52.38', {allowHybrid: false}));
+
+ }
+ },
+ {
+ name: "isUrlTest",
+ runTest: function(tests){
+
+ tests.t(dojox.validate.isUrl('www.yahoo.com'));
+ tests.t(dojox.validate.isUrl('http://www.yahoo.com'));
+ tests.t(dojox.validate.isUrl('https://www.yahoo.com'));
+ tests.f(dojox.validate.isUrl('http://.yahoo.com'));
+ tests.f(dojox.validate.isUrl('http://www.-yahoo.com'));
+ tests.f(dojox.validate.isUrl('http://www.yahoo-.com'));
+ tests.t(dojox.validate.isUrl('http://y-a---h-o-o.com'));
+ tests.t(dojox.validate.isUrl('http://www.y.com'));
+ tests.t(dojox.validate.isUrl('http://www.yahoo.museum'));
+ tests.t(dojox.validate.isUrl('http://www.yahoo.co.uk'));
+ tests.f(dojox.validate.isUrl('http://www.micro$oft.com'));
+
+ tests.t(dojox.validate.isUrl('http://www.y.museum:8080'));
+ tests.t(dojox.validate.isUrl('http://12.24.36.128:8080'));
+ tests.f(dojox.validate.isUrl('http://12.24.36.128:8080', {allowIP: false} ));
+ tests.t(dojox.validate.isUrl('www.y.museum:8080'));
+ tests.f(dojox.validate.isUrl('www.y.museum:8080', {scheme: true} ));
+ tests.t(dojox.validate.isUrl('localhost:8080', {allowLocal: true} ));
+ tests.f(dojox.validate.isUrl('localhost:8080', {} ));
+ tests.t(dojox.validate.isUrl('http://www.yahoo.com/index.html?a=12&b=hello%20world#anchor'));
+ tests.f(dojox.validate.isUrl('http://www.yahoo.xyz'));
+ tests.t(dojox.validate.isUrl('http://www.yahoo.com/index.html#anchor'));
+ tests.t(dojox.validate.isUrl('http://cocoon.apache.org/2.1/'));
+ }
+ },
+ {
+ name: "isEmailAddress",
+ runTest: function(tests) {
+ tests.t(dojox.validate.isEmailAddress('x@yahoo.com'));
+ tests.t(dojox.validate.isEmailAddress('x.y.z.w@yahoo.com'));
+ tests.f(dojox.validate.isEmailAddress('x..y.z.w@yahoo.com'));
+ tests.f(dojox.validate.isEmailAddress('x.@yahoo.com'));
+ tests.t(dojox.validate.isEmailAddress('x@z.com'));
+ tests.f(dojox.validate.isEmailAddress('x@yahoo.x'));
+ tests.t(dojox.validate.isEmailAddress('x@yahoo.museum'));
+ tests.t(dojox.validate.isEmailAddress("o'mally@yahoo.com"));
+ tests.f(dojox.validate.isEmailAddress("'mally@yahoo.com"));
+ tests.t(dojox.validate.isEmailAddress("fred&barney@stonehenge.com"));
+ tests.f(dojox.validate.isEmailAddress("fred&&barney@stonehenge.com"));
+
+ // local addresses
+ tests.t(dojox.validate.isEmailAddress("fred&barney@localhost", {allowLocal: true} ));
+ tests.f(dojox.validate.isEmailAddress("fred&barney@localhost"));
+
+ // addresses with cruft
+ tests.t(dojox.validate.isEmailAddress("mailto:fred&barney@stonehenge.com", {allowCruft: true} ));
+ tests.t(dojox.validate.isEmailAddress("<fred&barney@stonehenge.com>", {allowCruft: true} ));
+ tests.f(dojox.validate.isEmailAddress("mailto:fred&barney@stonehenge.com"));
+ tests.f(dojox.validate.isEmailAddress("<fred&barney@stonehenge.com>"));
+
+ // local addresses with cruft
+ tests.t(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowLocal: true, allowCruft: true} ));
+ tests.f(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowCruft: true} ));
+ tests.f(dojox.validate.isEmailAddress("<mailto:fred&barney@localhost>", {allowLocal: true} ));
+ }
+ },
+ {
+ name: "isEmailsAddressList",
+ runTest: function(tests) {
+ tests.t(dojox.validate.isEmailAddressList(
+ "x@yahoo.com \n x.y.z.w@yahoo.com ; o'mally@yahoo.com , fred&barney@stonehenge.com \n" )
+ );
+ tests.t(dojox.validate.isEmailAddressList(
+ "x@yahoo.com \n x.y.z.w@localhost \n o'mally@yahoo.com \n fred&barney@localhost",
+ {allowLocal: true} )
+ );
+ tests.f(dojox.validate.isEmailAddressList(
+ "x@yahoo.com; x.y.z.w@localhost; o'mally@yahoo.com; fred&barney@localhost", {listSeparator: ";"} )
+ );
+ tests.t(dojox.validate.isEmailAddressList(
+ "mailto:x@yahoo.com; <x.y.z.w@yahoo.com>; <mailto:o'mally@yahoo.com>; fred&barney@stonehenge.com",
+ {allowCruft: true, listSeparator: ";"} )
+ );
+ tests.f(dojox.validate.isEmailAddressList(
+ "mailto:x@yahoo.com; <x.y.z.w@yahoo.com>; <mailto:o'mally@yahoo.com>; fred&barney@stonehenge.com",
+ {listSeparator: ";"} )
+ );
+ tests.t(dojox.validate.isEmailAddressList(
+ "mailto:x@yahoo.com; <x.y.z.w@localhost>; <mailto:o'mally@localhost>; fred&barney@localhost",
+ {allowLocal: true, allowCruft: true, listSeparator: ";"} )
+ );
+ }
+ },
+ {
+ name: "getEmailAddressList",
+ runTest: function(tests) {
+ var list = "x@yahoo.com \n x.y.z.w@yahoo.com ; o'mally@yahoo.com , fred&barney@stonehenge.com";
+ tests.is(4, dojox.validate.getEmailAddressList(list).length);
+
+ var localhostList = "x@yahoo.com; x.y.z.w@localhost; o'mally@yahoo.com; fred&barney@localhost";
+ tests.is(0, dojox.validate.getEmailAddressList(localhostList).length);
+ tests.is(4, dojox.validate.getEmailAddressList(localhostList, {allowLocal: true} ).length);
+ }
+ },
+ {
+ name: "isInRangeInt",
+ runTest: function(tests) {
+ // test integers
+ tests.f(dojox.validate.isInRange( '0', {min: 1, max: 100} ));
+ tests.t(dojox.validate.isInRange( '1', {min: 1, max: 100} ));
+ tests.f(dojox.validate.isInRange( '-50', {min: 1, max: 100} ));
+ tests.t(dojox.validate.isInRange( '+50', {min: 1, max: 100} ));
+ tests.t(dojox.validate.isInRange( '100', {min: 1, max: 100} ));
+ tests.f(dojox.validate.isInRange( '101', {min: 1, max: 100} ));
+ }
+ },
+ {
+ name:"isInRangeReal",
+ runTest: function(tests){
+
+ tests.f(dojox.validate.isInRange( '0.9', {min: 1.0, max: 10.0} ));
+ tests.t(dojox.validate.isInRange( '1.0', {min: 1.0, max: 10.0} ));
+ tests.f(dojox.validate.isInRange( '-5.0', {min: 1.0, max: 10.0} ));
+ tests.t(dojox.validate.isInRange( '+5.50', {min: 1.0, max: 10.0} ));
+ tests.t(dojox.validate.isInRange( '10.0', {min: 1.0, max: 10.0} ));
+ tests.f(dojox.validate.isInRange( '10.1', {min: 1.0, max: 10.0} ));
+ tests.f(dojox.validate.isInRange( '5.566e28', {min: 5.567e28, max: 6.000e28} ));
+ tests.t(dojox.validate.isInRange( '5.7e28', {min: 5.567e28, max: 6.000e28} ));
+ tests.f(dojox.validate.isInRange( '6.00000001e28', {min: 5.567e28, max: 6.000e28} ));
+ tests.f(dojox.validate.isInRange( '10.000.000,12345e-5', {decimal: ",", max: 10000000.1e-5} ));
+ tests.f(dojox.validate.isInRange( '10.000.000,12345e-5', {decimal: ",", min: 10000000.2e-5} ));
+ tests.t(dojox.validate.isInRange('1,500,000', {separator: ',', min: 0}));
+ tests.f(dojox.validate.isInRange('1,500,000', {separator: ',', min: 1000, max: 20000}));
+ }
+ },
+ {
+
+ name:"isInRangeCurrency",
+ runTest: function(test){
+
+ tests.f(dojox.validate.isInRange('\u20AC123,456,789', {max: 123456788, symbol: '\u20AC'} ));
+ tests.f(dojox.validate.isInRange('\u20AC123,456,789', { min: 123456790, symbol: '\u20AC'} ));
+ tests.f(dojox.validate.isInRange('$123,456,789.07', { max: 123456789.06} ));
+ tests.f(dojox.validate.isInRange('$123,456,789.07', { min: 123456789.08} ));
+ tests.f(dojox.validate.isInRange('123.456.789,00 \u20AC', {max: 123456788, decimal: ",", symbol: '\u20AC'} ));
+ tests.f(dojox.validate.isInRange('123.456.789,00 \u20AC', {min: 123456790, decimal: ",", symbol: '\u20AC'} ));
+ tests.f(dojox.validate.isInRange('- T123 456 789-00', {decimal: "-", min:0} ));
+ tests.t(dojox.validate.isInRange('\u20AC123,456,789', { max: 123456790, symbol: '\u20AC'} ));
+ tests.t(dojox.validate.isInRange('$123,456,789.07', { min: 123456789.06} ));
+ // test non number
+ //tests.f("test25", dojox.validate.isInRange( 'a'));
+ }
+ },
+ {
+ name: "isUsPhoneNumber",
+ runTest: function(tests) {
+ tests.t(dojox.validate.us.isPhoneNumber('(111) 111-1111'));
+ tests.t(dojox.validate.us.isPhoneNumber('(111) 111 1111'));
+ tests.t(dojox.validate.us.isPhoneNumber('111 111 1111'));
+ tests.t(dojox.validate.us.isPhoneNumber('111.111.1111'));
+ tests.t(dojox.validate.us.isPhoneNumber('111-111-1111'));
+ tests.t(dojox.validate.us.isPhoneNumber('111/111-1111'));
+ tests.f(dojox.validate.us.isPhoneNumber('111 111-1111'));
+ tests.f(dojox.validate.us.isPhoneNumber('111-1111'));
+ tests.f(dojox.validate.us.isPhoneNumber('(111)-111-1111'));
+
+ // test extensions
+ tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x1'));
+ tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x12'));
+ tests.t(dojox.validate.us.isPhoneNumber('111-111-1111 x1234'));
+ }
+ },
+ {
+ name: "isUsSocialSecurityNumber",
+ runTest: function(tests) {
+ tests.t(dojox.validate.us.isSocialSecurityNumber('123-45-6789'));
+ tests.t(dojox.validate.us.isSocialSecurityNumber('123 45 6789'));
+ tests.t(dojox.validate.us.isSocialSecurityNumber('123456789'));
+ tests.f(dojox.validate.us.isSocialSecurityNumber('123-45 6789'));
+ tests.f(dojox.validate.us.isSocialSecurityNumber('12345 6789'));
+ tests.f(dojox.validate.us.isSocialSecurityNumber('123-456789'));
+ }
+ },
+ {
+ name:"isUsZipCode",
+ runTest: function(tests) {
+ tests.t(dojox.validate.us.isZipCode('12345-6789'));
+ tests.t(dojox.validate.us.isZipCode('12345 6789'));
+ tests.t(dojox.validate.us.isZipCode('123456789'));
+ tests.t(dojox.validate.us.isZipCode('12345'));
+ }
+ },
+ {
+ name:"isCaZipCode",
+ runTest: function(tests) {
+ tests.t(dojox.validate.ca.isPostalCode('A1Z 3F3'));
+ tests.f(dojox.validate.ca.isPostalCode('1AZ 3F3'));
+ tests.t(dojox.validate.ca.isPostalCode('a1z 3f3'));
+ tests.f(dojox.validate.ca.isPostalCode('xxxxxx'));
+ tests.t(dojox.validate.ca.isPostalCode('A1Z3F3'));
+
+ }
+ },
+ {
+ name:"isUsState",
+ runTest: function(tests) {
+ tests.t(dojox.validate.us.isState('CA'));
+ tests.t(dojox.validate.us.isState('ne'));
+ tests.t(dojox.validate.us.isState('PR'));
+ tests.f(dojox.validate.us.isState('PR', {allowTerritories: false} ));
+ tests.t(dojox.validate.us.isState('AA'));
+ tests.f(dojox.validate.us.isState('AA', {allowMilitary: false} ));
+ }
+ }
+]);
+
+}