1 | define(["doh", "../br"], function(doh, br){ |
---|
2 | |
---|
3 | doh.register("dojox.validate.tests.br",[ |
---|
4 | //Randomy generated valid CNJP/CGC numbers. |
---|
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 | }, |
---|
37 | { |
---|
38 | name:"computeCnpjDv", |
---|
39 | runTest: function(doh) { |
---|
40 | doh.assertEqual("03", br.computeCnpjDv('75.730.657/0001'), "1 Checking ##.###.###/#### format"); |
---|
41 | doh.assertEqual("03", br.computeCnpjDv('75730657/0001'), "1 Checking ########/#### format"); |
---|
42 | doh.assertEqual("03", br.computeCnpjDv('757306570001'), "1 Checking ############ format"); |
---|
43 | doh.assertEqual("03", br.computeCnpjDv(757306570001), "1 Checking numeric ############ format"); |
---|
44 | |
---|
45 | doh.assertEqual("01", br.computeCnpjDv('05.101.993/0001'), "2 Checking ##.###.###/#### format"); |
---|
46 | doh.assertEqual("01", br.computeCnpjDv('05101993/0001'), "2 Checking ########/#### format"); |
---|
47 | doh.assertEqual("01", br.computeCnpjDv('051019930001'), "2 Checking ############ format"); |
---|
48 | doh.assertEqual("01", br.computeCnpjDv(51019930001), "2 Checking numeric ############ format"); |
---|
49 | |
---|
50 | doh.assertEqual("17", br.computeCnpjDv('79.577.986/0001'), "3 Checking ##.###.###/#### format"); |
---|
51 | doh.assertEqual("17", br.computeCnpjDv('79577986/0001'), "3 Checking ########/#### format"); |
---|
52 | doh.assertEqual("17", br.computeCnpjDv('795779860001'), "3 Checking ############ format"); |
---|
53 | doh.assertEqual("17", br.computeCnpjDv(795779860001), "3 Checking numeric ############ format"); |
---|
54 | } |
---|
55 | }, |
---|
56 | //All CPF numbers randomly generated from: http://www.gerardocumentos.com.br |
---|
57 | { |
---|
58 | name:"isValidCpf", |
---|
59 | runTest: function(doh) { |
---|
60 | doh.assertTrue(br.isValidCpf('362.866.226-59'), "1 Checking ###.###.###-## format"); |
---|
61 | doh.assertTrue(br.isValidCpf('362866226-59'), "1 Checking #########-## format"); |
---|
62 | doh.assertTrue(br.isValidCpf('36286622659'), "1 Checking ########### format"); |
---|
63 | doh.assertTrue(br.isValidCpf(36286622659), "1 Checking numeric ########### format"); |
---|
64 | |
---|
65 | doh.assertTrue(br.isValidCpf('781.215.062-39'), "2 Checking ###.###.###-## format"); |
---|
66 | doh.assertTrue(br.isValidCpf('781215062-39'), "2 Checking #########-## format"); |
---|
67 | doh.assertTrue(br.isValidCpf('78121506239'), "2 Checking ########### format"); |
---|
68 | doh.assertTrue(br.isValidCpf(78121506239), "2 Checking numeric ########### format"); |
---|
69 | |
---|
70 | doh.assertTrue(br.isValidCpf('670.832.400-86'), "3 Checking ###.###.###-## format"); |
---|
71 | doh.assertTrue(br.isValidCpf('670832400-86'), "3 Checking #########-## format"); |
---|
72 | doh.assertTrue(br.isValidCpf('67083240086'), "3 Checking ########### format"); |
---|
73 | doh.assertTrue(br.isValidCpf(67083240086), "3 Checking numeric ########### format"); |
---|
74 | |
---|
75 | doh.assertTrue(br.isValidCpf('271.034.755-55'), "4 Checking ###.###.###-## format"); |
---|
76 | doh.assertTrue(br.isValidCpf('271034755-55'), "4 Checking #########-## format"); |
---|
77 | doh.assertTrue(br.isValidCpf('27103475555'), "4 Checking ########### format"); |
---|
78 | doh.assertTrue(br.isValidCpf(27103475555), "4 Checking numeric ########### format"); |
---|
79 | } |
---|
80 | }, |
---|
81 | { |
---|
82 | name:"computeCpfDv", |
---|
83 | runTest: function(doh) { |
---|
84 | doh.assertEqual("59", br.computeCpfDv('362.866.226'), "1 Checking ###.###.### format"); |
---|
85 | doh.assertEqual("59", br.computeCpfDv('362866226'), "1 Checking ######### format"); |
---|
86 | doh.assertEqual("59", br.computeCpfDv(362866226), "1 Checking numeric ######### format"); |
---|
87 | |
---|
88 | doh.assertEqual("39", br.computeCpfDv('781.215.062'), "2 Checking ###.###.### format"); |
---|
89 | doh.assertEqual("39", br.computeCpfDv('781215062'), "2 Checking ######### format"); |
---|
90 | doh.assertEqual("39", br.computeCpfDv(781215062), "2 Checking numeric ######### format"); |
---|
91 | |
---|
92 | doh.assertEqual("86", br.computeCpfDv('670.832.400'), "3 Checking ###.###.### format"); |
---|
93 | doh.assertEqual("86", br.computeCpfDv('670832400'), "3 Checking ######### format"); |
---|
94 | doh.assertEqual("86", br.computeCpfDv(670832400), "3 Checking numeric ######### format"); |
---|
95 | |
---|
96 | doh.assertEqual("55", br.computeCpfDv('271.034.755'), "4 Checking ###.###.### format"); |
---|
97 | doh.assertEqual("55", br.computeCpfDv('271034755'), "4 Checking ######### format"); |
---|
98 | doh.assertEqual("55", br.computeCpfDv(271034755), "4 Checking numeric ######### format"); |
---|
99 | |
---|
100 | } |
---|
101 | } |
---|
102 | ]); |
---|
103 | |
---|
104 | }); |
---|