diff --git a/qed/country-specific.md b/qed/country-specific.md index f5ec7aff..a0d24e0f 100644 --- a/qed/country-specific.md +++ b/qed/country-specific.md @@ -6,20 +6,14 @@ #### NANP -```ruby - nanp = Phony['1'] - - nanp.format('5551234567890', :format => :international).assert == '+1 (555) 123-4567890' - nanp.format('5551234567890', :format => :national).assert == '(555) 123-4567890' - nanp.format('5551234567890', :format => :local).assert == '123-4567890' - - nanp.normalize("555 1234567890").assert == '5551234567890' - nanp.normalize("+1 555 1234567890").assert == '5551234567890' - nanp.normalize("+1 (0) 555 1234567890").assert == '5551234567890' - nanp.normalize('4159224711').assert == '4159224711' - - nanp.assert.plausible?('4159224711') -``` + nanp = Phony['1'] + + nanp.format('5551234567890', :format => :international).assert == '+1 (555) 123-4567890' + nanp.format('5551234567890', :format => :national).assert == '(555) 123-4567890' + nanp.format('5551234567890', :format => :local).assert == '123-4567890' + + nanp.normalize("555 1234567890").assert == '5551234567890' + nanp.normalize('4159224711').assert == '4159224711' Important: It is not expected to handle an international number correctly. This fails: @@ -29,6 +23,11 @@ Only expects and handles normalized national numbers: Phony["81"].format('312345634', :format => :international).assert == '+81 3-1234-5634' +But note that these will not fail, as the contained numbers are still a NANP number. + + nanp.normalize("+1 555 1234567890").assert == '15551234567890' + nanp.normalize("+1 (0) 555 1234567890").assert == '15551234567890' + #### Japan The domestic Telephone number in Japan has to have Trunk prefix. diff --git a/qed/normalize.md b/qed/normalize.md index baa6d08c..38468fe8 100644 --- a/qed/normalize.md +++ b/qed/normalize.md @@ -74,6 +74,7 @@ Handles a number with extra 0. #### Japan Phony.normalize('+81 3-1234-5634').assert == '81312345634' + Phony.normalize('3-1234-5634', cc: '81').assert == '81312345634' Phony.normalize('03-1234-5634', cc: '81').assert == '81312345634' #### Lithuania diff --git a/spec/lib/phony/country_spec.rb b/spec/lib/phony/country_spec.rb index be1ada16..979ef226 100644 --- a/spec/lib/phony/country_spec.rb +++ b/spec/lib/phony/country_spec.rb @@ -43,6 +43,11 @@ Phony.normalize('+378903549').should == '3780549903549' end end + describe 'Japan' do + it 'normalizes correctly' do + Phony.normalize('03-1234-5634', cc: '81').should == '81312345634' + end + end end context "without special cases (with switzerland)" do