| 1 |
define(["doh", "../br"], function(doh, br){ |
| 2 |
|
| 3 |
doh.register("dojox.validate.tests.br",[ |
| 4 |
|
| 5 |
{ |
| 6 |
name:"isValidCnpj", |
| 7 |
runTest: function(doh) { |
| 8 |
doh.assertTrue(br.isValidCnpj('75.730.657/0001-03'), "1 Checking ##.###.###/####-## format"); |
| 9 |
doh.assertTrue(br.isValidCnpj('75730657/0001-03'), "1 Checking ########/####-## format"); |
| 10 |
doh.assertTrue(br.isValidCnpj('757306570001-03'), "1 Checking ############-## format"); |
| 11 |
doh.assertTrue(br.isValidCnpj('75730657000103'), "1 Checking ############## format"); |
| 12 |
doh.assertTrue(br.isValidCnpj(75730657000103), "1 Checking numeric ############## format"); |
| 13 |
|
| 14 |
doh.assertTrue(br.isValidCnpj('05.101.993/0001-01'), "2 Checking ##.###.###/####-## format"); |
| 15 |
doh.assertTrue(br.isValidCnpj('05101993/0001-01'), "2 Checking ########/####-## format"); |
| 16 |
doh.assertTrue(br.isValidCnpj('051019930001-01'), "2 Checking ############-## format"); |
| 17 |
doh.assertTrue(br.isValidCnpj('05101993000101'), "2 Checking ############## format"); |
| 18 |
doh.assertTrue(br.isValidCnpj(5101993000101), "2 Checking numeric ############## format"); |
| 19 |
|
| 20 |
doh.assertTrue(br.isValidCnpj('79.577.986/0001-17'), "3 Checking ##.###.###/####-## format"); |
| 21 |
doh.assertTrue(br.isValidCnpj('79577986/0001-17'), "3 Checking ########/####-## format"); |
| 22 |
doh.assertTrue(br.isValidCnpj('795779860001-17'), "3 Checking ############-## format"); |
| 23 |
doh.assertTrue(br.isValidCnpj('79577986000117'), "3 Checking ############## format"); |
| 24 |
doh.assertTrue(br.isValidCnpj(79577986000117), "3 Checking numeric ############## format"); |
| 25 |
|
| 26 |
doh.assertFalse(br.isValidCnpj('79.577.986/0001-18'), "4 Checking ##.###.###/####-## format"); |
| 27 |
doh.assertFalse(br.isValidCnpj('79577986/0001-18'), "4 Checking ########/####-## format"); |
| 28 |
doh.assertFalse(br.isValidCnpj('795779860001-18'), "4 Checking ############-## format"); |
| 29 |
doh.assertFalse(br.isValidCnpj('79577986000118'), "4 Checking ############## format"); |
| 30 |
doh.assertFalse(br.isValidCnpj(79577986000118), "4 Checking numeric ############## format"); |
| 31 |
doh.assertFalse(br.isValidCnpj(0), "5 Checking numeric ############## format"); |
| 32 |
doh.assertFalse(br.isValidCnpj('00000000000000'), "4 Checking numeric ############## format"); |
| 33 |
doh.assertFalse(br.isValidCnpj('11111111111111'), "4 Checking numeric ############## format"); |
| 34 |
doh.assertFalse(br.isValidCnpj('22222222222222'), "4 Checking numeric ############## format"); |
| 35 |
|
| 36 |
doh.assertTrue(br.isValidCnpj('00.835.530/0001-50'), "5 Checking 00.835.530/0001-50 should be valid"); |
| 37 |
doh.assertTrue(br.isValidCnpj('00835530000150'), "5 Checking 00835530000150 should be valid"); |
| 38 |
doh.assertTrue(br.isValidCnpj(00835530000150), "5 Checking numeric 00835530000150 should be valid"); |
| 39 |
} |
| 40 |
}, |
| 41 |
{ |
| 42 |
name:"computeCnpjDv", |
| 43 |
runTest: function(doh) { |
| 44 |
doh.assertEqual("03", br.computeCnpjDv('75.730.657/0001'), "1 Checking ##.###.###/#### format"); |
| 45 |
doh.assertEqual("03", br.computeCnpjDv('75730657/0001'), "1 Checking ########/#### format"); |
| 46 |
doh.assertEqual("03", br.computeCnpjDv('757306570001'), "1 Checking ############ format"); |
| 47 |
doh.assertEqual("03", br.computeCnpjDv(757306570001), "1 Checking numeric ############ format"); |
| 48 |
|
| 49 |
doh.assertEqual("01", br.computeCnpjDv('05.101.993/0001'), "2 Checking ##.###.###/#### format"); |
| 50 |
doh.assertEqual("01", br.computeCnpjDv('05101993/0001'), "2 Checking ########/#### format"); |
| 51 |
doh.assertEqual("01", br.computeCnpjDv('051019930001'), "2 Checking ############ format"); |
| 52 |
doh.assertEqual("01", br.computeCnpjDv(51019930001), "2 Checking numeric ############ format"); |
| 53 |
|
| 54 |
doh.assertEqual("17", br.computeCnpjDv('79.577.986/0001'), "3 Checking ##.###.###/#### format"); |
| 55 |
doh.assertEqual("17", br.computeCnpjDv('79577986/0001'), "3 Checking ########/#### format"); |
| 56 |
doh.assertEqual("17", br.computeCnpjDv('795779860001'), "3 Checking ############ format"); |
| 57 |
doh.assertEqual("17", br.computeCnpjDv(795779860001), "3 Checking numeric ############ format"); |
| 58 |
|
| 59 |
doh.assertEqual("50", br.computeCnpjDv('00.835.530/0001'), "4 Checking 00.835.530/0001"); |
| 60 |
doh.assertEqual("50", br.computeCnpjDv('008355300001'), "4 Checking 008355300001"); |
| 61 |
doh.assertEqual("50", br.computeCnpjDv(008355300001), "4 Checking numeric 008355300001"); |
| 62 |
} |
| 63 |
}, |
| 64 |
|
| 65 |
{ |
| 66 |
name:"isValidCpf", |
| 67 |
runTest: function(doh) { |
| 68 |
doh.assertTrue(br.isValidCpf('362.866.226-59'), "1 Checking ###.###.###-## format"); |
| 69 |
doh.assertTrue(br.isValidCpf('362866226-59'), "1 Checking #########-## format"); |
| 70 |
doh.assertTrue(br.isValidCpf('36286622659'), "1 Checking ########### format"); |
| 71 |
doh.assertTrue(br.isValidCpf(36286622659), "1 Checking numeric ########### format"); |
| 72 |
|
| 73 |
doh.assertTrue(br.isValidCpf('781.215.062-39'), "2 Checking ###.###.###-## format"); |
| 74 |
doh.assertTrue(br.isValidCpf('781215062-39'), "2 Checking #########-## format"); |
| 75 |
doh.assertTrue(br.isValidCpf('78121506239'), "2 Checking ########### format"); |
| 76 |
doh.assertTrue(br.isValidCpf(78121506239), "2 Checking numeric ########### format"); |
| 77 |
|
| 78 |
doh.assertTrue(br.isValidCpf('670.832.400-86'), "3 Checking ###.###.###-## format"); |
| 79 |
doh.assertTrue(br.isValidCpf('670832400-86'), "3 Checking #########-## format"); |
| 80 |
doh.assertTrue(br.isValidCpf('67083240086'), "3 Checking ########### format"); |
| 81 |
doh.assertTrue(br.isValidCpf(67083240086), "3 Checking numeric ########### format"); |
| 82 |
|
| 83 |
doh.assertTrue(br.isValidCpf('271.034.755-55'), "4 Checking ###.###.###-## format"); |
| 84 |
doh.assertTrue(br.isValidCpf('271034755-55'), "4 Checking #########-## format"); |
| 85 |
doh.assertTrue(br.isValidCpf('27103475555'), "4 Checking ########### format"); |
| 86 |
doh.assertTrue(br.isValidCpf(27103475555), "4 Checking numeric ########### format"); |
| 87 |
|
| 88 |
doh.assertTrue(br.isValidCpf('066.487.679-01'), "5 Checking 066.487.679-01 should be valid"); |
| 89 |
doh.assertTrue(br.isValidCpf(06648767901), "5 Checking numeric 06648767901 should be valid"); |
| 90 |
} |
| 91 |
}, |
| 92 |
{ |
| 93 |
name:"computeCpfDv", |
| 94 |
runTest: function(doh) { |
| 95 |
doh.assertEqual("59", br.computeCpfDv('362.866.226'), "1 Checking ###.###.### format"); |
| 96 |
doh.assertEqual("59", br.computeCpfDv('362866226'), "1 Checking ######### format"); |
| 97 |
doh.assertEqual("59", br.computeCpfDv(362866226), "1 Checking numeric ######### format"); |
| 98 |
|
| 99 |
doh.assertEqual("39", br.computeCpfDv('781.215.062'), "2 Checking ###.###.### format"); |
| 100 |
doh.assertEqual("39", br.computeCpfDv('781215062'), "2 Checking ######### format"); |
| 101 |
doh.assertEqual("39", br.computeCpfDv(781215062), "2 Checking numeric ######### format"); |
| 102 |
|
| 103 |
doh.assertEqual("86", br.computeCpfDv('670.832.400'), "3 Checking ###.###.### format"); |
| 104 |
doh.assertEqual("86", br.computeCpfDv('670832400'), "3 Checking ######### format"); |
| 105 |
doh.assertEqual("86", br.computeCpfDv(670832400), "3 Checking numeric ######### format"); |
| 106 |
|
| 107 |
doh.assertEqual("55", br.computeCpfDv('271.034.755'), "4 Checking ###.###.### format"); |
| 108 |
doh.assertEqual("55", br.computeCpfDv('271034755'), "4 Checking ######### format"); |
| 109 |
doh.assertEqual("55", br.computeCpfDv(271034755), "4 Checking numeric ######### format"); |
| 110 |
|
| 111 |
doh.assertEqual("01", br.computeCpfDv('066.487.679'), "6 Checking 066.487.679-01"); |
| 112 |
doh.assertEqual("01", br.computeCpfDv(066487679), "6 Checking numeric 06648767901"); |
| 113 |
} |
| 114 |
} |
| 115 |
]); |
| 116 |
|
| 117 |
}); |