Skip to content

Commit e05f7b8

Browse files
committed
add three more test cases #1
1 parent bf9d917 commit e05f7b8

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
}
8181

8282
function isCodeValid (num) {
83-
var wc = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
83+
var wc = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];
8484
var validCodeArr = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2];
8585
var sum = 0;
8686
var temp = num.split('');

test/test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ describe('Validate', function () {
9191
});
9292
});
9393

94+
describe('#isChineseTel', function () {
95+
it('should validate Chinese cell phone number', function () {
96+
test({
97+
validator: 'isChineseTel',
98+
valid: [
99+
'14700000000',
100+
'17700000000',
101+
'13513513511',
102+
'13838385438'
103+
],
104+
invalid: [
105+
'33312341241',
106+
'1341231421',
107+
'133141212441'
108+
]
109+
});
110+
});
111+
});
112+
94113
describe('#isAllDigit', function () {
95114
it('should validate all digits', function () {
96115
test({
@@ -107,4 +126,20 @@ describe('Validate', function () {
107126
});
108127
});
109128

129+
describe('#isChineseIdCard', function () {
130+
it('should validate an Chinese Id Card', function () {
131+
test({
132+
validator: 'isChineseIdCard',
133+
valid: [
134+
'15210319861215033x'
135+
],
136+
invalid: [
137+
'1234',
138+
'12345678910111213x',
139+
'123456789112312345'
140+
]
141+
});
142+
});
143+
});
144+
110145
});

0 commit comments

Comments
 (0)