RFC3966.test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { parseRFC3966, formatRFC3966 } from './RFC3966.js';
  2. describe('RFC3966', function () {
  3. it('should format', function () {
  4. expect(function () {
  5. return formatRFC3966({
  6. number: '123'
  7. });
  8. }).to["throw"]('expects "number" to be in E.164 format');
  9. formatRFC3966({}).should.equal('');
  10. formatRFC3966({
  11. number: '+78005553535'
  12. }).should.equal('tel:+78005553535');
  13. formatRFC3966({
  14. number: '+78005553535',
  15. ext: '123'
  16. }).should.equal('tel:+78005553535;ext=123');
  17. });
  18. it('should parse', function () {
  19. parseRFC3966('tel:+78005553535').should.deep.equal({
  20. number: '+78005553535'
  21. });
  22. parseRFC3966('tel:+78005553535;ext=123').should.deep.equal({
  23. number: '+78005553535',
  24. ext: '123'
  25. }); // With `phone-context`
  26. parseRFC3966('tel:8005553535;ext=123;phone-context=+7').should.deep.equal({
  27. number: '+78005553535',
  28. ext: '123'
  29. }); // "Domain contexts" are ignored
  30. parseRFC3966('tel:8005553535;ext=123;phone-context=www.leningrad.spb.ru').should.deep.equal({
  31. number: '8005553535',
  32. ext: '123'
  33. }); // Not a viable phone number.
  34. parseRFC3966('tel:3').should.deep.equal({});
  35. });
  36. });
  37. //# sourceMappingURL=RFC3966.test.js.map