|
68 | 68 | end
|
69 | 69 |
|
70 | 70 | describe 'PhonyRails#normalize_number' do
|
71 |
| - it "should normalize a number with a default_country_code" do |
72 |
| - PhonyRails.normalize_number('010-1234123', :default_country_code => 'NL').should eql('31101234123') |
73 |
| - end |
| 71 | + context 'number with a country code' do |
| 72 | + |
| 73 | + it "should not add default_country_code" do |
| 74 | + PhonyRails.normalize_number('+4790909090', :default_country_code => 'SE').should eql('4790909090') # SE = +46 |
| 75 | + end |
| 76 | + |
| 77 | + it "should force add country_code" do |
| 78 | + PhonyRails.normalize_number('+4790909090', :country_code => 'SE').should eql('464790909090') |
| 79 | + end |
74 | 80 |
|
75 |
| - it "should normalize a number with a country_code" do |
76 |
| - PhonyRails.normalize_number('010-1234123', :country_code => 'NL', :default_country_code => 'DE').should eql('31101234123') |
77 |
| - PhonyRails.normalize_number('010-1234123', :country_code => 'NL').should eql('31101234123') |
78 | 81 | end
|
79 | 82 |
|
80 |
| - it "should handle different countries" do |
81 |
| - PhonyRails.normalize_number('(030) 8 61 29 06', :country_code => 'DE').should eql('49308612906') |
82 |
| - PhonyRails.normalize_number('+43 664 3830412', :country_code => 'AT').should eql('436643830412') |
83 |
| - PhonyRails.normalize_number('0203 330 8897', :country_code => 'GB').should eql('442033308897') |
| 83 | + context 'number without a country code' do |
| 84 | + |
| 85 | + it "should normalize with a default_country_code" do |
| 86 | + PhonyRails.normalize_number('010-1234123', :default_country_code => 'NL').should eql('31101234123') |
| 87 | + end |
| 88 | + |
| 89 | + it "should normalize with a country_code" do |
| 90 | + PhonyRails.normalize_number('010-1234123', :country_code => 'NL', :default_country_code => 'DE').should eql('31101234123') |
| 91 | + PhonyRails.normalize_number('010-1234123', :country_code => 'NL').should eql('31101234123') |
| 92 | + end |
| 93 | + |
| 94 | + it "should handle different countries" do |
| 95 | + PhonyRails.normalize_number('(030) 8 61 29 06', :country_code => 'DE').should eql('49308612906') |
| 96 | + PhonyRails.normalize_number('0203 330 8897', :country_code => 'GB').should eql('442033308897') |
| 97 | + end |
| 98 | + |
| 99 | + it "should prefer country_code over default_country_code" do |
| 100 | + PhonyRails.normalize_number('(030) 8 61 29 06', :country_code => 'DE', :default_country_code => 'NL').should eql('49308612906') |
| 101 | + end |
| 102 | + |
84 | 103 | end
|
85 | 104 |
|
86 | 105 | it "should handle some edge cases" do
|
|
0 commit comments