formatIncompletePhoneNumber.test.js 1.0 KB

1234567891011121314151617181920212223242526
  1. import formatIncompletePhoneNumber from './formatIncompletePhoneNumber.js'
  2. import metadata from '../metadata.min.json' assert { type: 'json' }
  3. describe('formatIncompletePhoneNumber', () => {
  4. it('should format parsed input value', () => {
  5. let result
  6. // National input.
  7. formatIncompletePhoneNumber('880055535', 'RU', metadata).should.equal('8 (800) 555-35')
  8. // International input, no country.
  9. formatIncompletePhoneNumber('+780055535', null, metadata).should.equal('+7 800 555 35')
  10. // International input, no country argument.
  11. formatIncompletePhoneNumber('+780055535', metadata).should.equal('+7 800 555 35')
  12. // International input, with country.
  13. formatIncompletePhoneNumber('+780055535', 'RU', metadata).should.equal('+7 800 555 35')
  14. })
  15. it('should support an object argument', () => {
  16. formatIncompletePhoneNumber('880055535', { defaultCountry: 'RU' }, metadata).should.equal('8 (800) 555-35')
  17. formatIncompletePhoneNumber('880055535', { defaultCallingCode: '7' }, metadata).should.equal('8 (800) 555-35')
  18. })
  19. })