-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelephoneNumberValidator.test.js
125 lines (97 loc) · 4.14 KB
/
telephoneNumberValidator.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const telephoneCheck = require('../telephone-number-validator/telephoneNumberValidator');
describe('Testing telephoneCheck function', () => {
describe('Testing function return', () => {
test('Checks if the returned value is boolean', () => {
expect(telephoneCheck('555-555-5555')).toBe(true);
expect(telephoneCheck('55555-5555')).toBe(false);
expect(telephoneCheck('555-555-5555')).not.toBe('555-555-5555');
});
});
describe('Testing cases that must return true', () => {
const resultTest = true;
test('Testing with the string "1 555-555-5555"', () => {
expect(telephoneCheck('1 555-555-5555')).toBe(resultTest);
});
test('Testing with the string "1 (555) 555-5555"', () => {
expect(telephoneCheck('1 (555) 555-5555')).toBe(resultTest);
});
test('Testing with the string "5555555555"', () => {
expect(telephoneCheck('5555555555')).toBe(resultTest);
});
test('Testing with the string "555-555-5555"', () => {
expect(telephoneCheck('555-555-5555')).toBe(resultTest);
});
test('Testing with the string "(555)555-5555"', () => {
expect(telephoneCheck('(555)555-5555')).toBe(resultTest);
});
test('Testing with the string "1(555)555-5555"', () => {
expect(telephoneCheck('1(555)555-5555')).toBe(resultTest);
});
test('Testing with the string "1 555 555 5555"', () => {
expect(telephoneCheck('1 555 555 5555')).toBe(resultTest);
});
test('Testing with the string "1 456 789 4444"', () => {
expect(telephoneCheck('1 456 789 4444')).toBe(resultTest);
});
});
describe('Testing cases that must return false', () => {
const resultTest = false;
test('Testing with the string "555-5555"', () => {
expect(telephoneCheck('555-5555')).toBe(resultTest);
});
test('Testing with the string "5555555"', () => {
expect(telephoneCheck('5555555')).toBe(resultTest);
});
test('Testing with the string "1 555)555-5555"', () => {
expect(telephoneCheck('1 555)555-5555')).toBe(resultTest);
});
test('Testing with the string "123**&!!asdf#"', () => {
expect(telephoneCheck('123**&!!asdf#')).toBe(resultTest);
});
test('Testing with the string "55555555"', () => {
expect(telephoneCheck('55555555')).toBe(resultTest);
});
test('Testing with the string "(6054756961)"', () => {
expect(telephoneCheck('(6054756961)')).toBe(resultTest);
});
test('Testing with the string "2 (757) 622-7382"', () => {
expect(telephoneCheck('2 (757) 622-7382')).toBe(resultTest);
});
test('Testing with the string "0 (757) 622-7382"', () => {
expect(telephoneCheck('0 (757) 622-7382')).toBe(resultTest);
});
test('Testing with the string "-1 (757) 622-7382"', () => {
expect(telephoneCheck('-1 (757) 622-7382')).toBe(resultTest);
});
test('Testing with the string "2 757 622-7382"', () => {
expect(telephoneCheck('2 757 622-7382')).toBe(resultTest);
});
test('Testing with the string "10 (757) 622-7382"', () => {
expect(telephoneCheck('10 (757) 622-7382')).toBe(resultTest);
});
test('Testing with the string "27576227382"', () => {
expect(telephoneCheck('27576227382')).toBe(resultTest);
});
test('Testing with the string "(275)76227382"', () => {
expect(telephoneCheck('(275)76227382')).toBe(resultTest);
});
test('Testing with the string "2(757)6227382"', () => {
expect(telephoneCheck('2(757)6227382')).toBe(resultTest);
});
test('Testing with the string "2(757)622-7382"', () => {
expect(telephoneCheck('2(757)622-7382')).toBe(resultTest);
});
test('Testing with the string "555)-555-5555"', () => {
expect(telephoneCheck('555)-555-5555')).toBe(resultTest);
});
test('Testing with the string "(555-555-5555"', () => {
expect(telephoneCheck('(555-555-5555')).toBe(resultTest);
});
test('Testing with the string "(555)5(55?)-5555"', () => {
expect(telephoneCheck('(555)5(55?)-5555')).toBe(resultTest);
});
test('Testing with the string "55 55-55-555-5"', () => {
expect(telephoneCheck('55 55-55-555-5')).toBe(resultTest);
});
});
});