@@ -3,6 +3,7 @@ var phone = require('..');
33
44describe ( 'phone-regex' , function ( ) {
55
6+ // !indian exact
67 describe ( 'exact: true' , function ( ) {
78
89 it ( 'should find a (XXX) XXX-XXXX phone number when it exists' , function ( ) {
@@ -42,6 +43,45 @@ describe('phone-regex', function() {
4243 } ) ;
4344 } ) ;
4445
46+ // indian !exact
47+ describe ( 'indian: true' , function ( ) {
48+
49+ it ( 'should find an Indian phone number when it exists' , function ( ) {
50+ assert . equal ( phone ( { indian : true } ) . test ( 'mangoes +91 9744142626' ) , true ) ;
51+ } ) ;
52+
53+ it ( 'should find all Indian phone numbers in a string' , function ( ) {
54+ assert . equal ( '+91 9744142626 orange 04842 274162' . match ( phone ( { indian : true } ) ) . length , 2 ) ;
55+ } ) ;
56+
57+ it ( 'should not find phone numbers when they do not exist' , function ( ) {
58+ assert . equal ( 'pineapples' . match ( phone ( { indian : true } ) ) , null ) ;
59+ } ) ;
60+
61+ } ) ;
62+
63+ // indian exact
64+ describe ( 'indian: true, exact: true' , function ( ) {
65+
66+ it ( 'should find a (+91 XXXXXXXXXX) phone number when it exists' , function ( ) {
67+ assert . equal ( phone ( { indian : true , exact : true } ) . test ( '+91 9744142626' ) , true ) ;
68+ } ) ;
69+
70+ it ( 'should find a (XXXXX XXXXXX) phone number when it exists' , function ( ) {
71+ assert . equal ( phone ( { indian : true , exact : true } ) . test ( '04842 274162' ) , true ) ;
72+ } ) ;
73+
74+ it ( 'should find a (XXXXXXXXXX) phone number when it exists' , function ( ) {
75+ assert . equal ( phone ( { indian : true , exact : true } ) . test ( '9744142626' ) , true ) ;
76+ } ) ;
77+
78+ it ( 'should find a (XXXX - XXXXXXXXXX) phone number when it exists' , function ( ) {
79+ assert . equal ( phone ( { indian : true , exact : true } ) . test ( '0091 - 9744142626' ) , true ) ;
80+ } ) ;
81+
82+ } ) ;
83+
84+ // !indian !exact
4585 describe ( 'g' , function ( ) {
4686
4787 it ( 'should find a phone number when it exists' , function ( ) {
0 commit comments