Leniency.test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. import { containsMoreThanOneSlashInNationalNumber } from './Leniency.js'
  3. describe('Leniency', () => {
  4. it('testContainsMoreThanOneSlashInNationalNumber', () => {
  5. // A date should return true.
  6. number.setCountryCode(1)
  7. number.setCountryCodeSource(CountryCodeSource.FROM_DEFAULT_COUNTRY)
  8. containsMoreThanOneSlashInNationalNumber(number, '1/05/2013').should.equal(true)
  9. // Here, the country code source thinks it started with a country calling code, but this is not
  10. // the same as the part before the slash, so it's still true.
  11. number.setCountryCode(274)
  12. number.setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITHOUT_PLUS_SIGN)
  13. containsMoreThanOneSlashInNationalNumber(number, '27/4/2013').should.equal(true)
  14. // Now it should be false, because the first slash is after the country calling code.
  15. number.setCountryCode(49)
  16. number.setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN)
  17. containsMoreThanOneSlashInNationalNumber(number, '49/69/2013').should.equal(false)
  18. number.setCountryCode(49)
  19. number.setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITHOUT_PLUS_SIGN)
  20. containsMoreThanOneSlashInNationalNumber(number, '+49/69/2013').should.equal(false)
  21. containsMoreThanOneSlashInNationalNumber(number, '+ 49/69/2013').should.equal(false)
  22. containsMoreThanOneSlashInNationalNumber(number, '+ 49/69/20/13').should.equal(true)
  23. // Here, the first group is not assumed to be the country calling code, even though it is the
  24. // same as it, so this should return true.
  25. number.setCountryCode(49)
  26. number.setCountryCodeSource(CountryCodeSource.FROM_DEFAULT_COUNTRY)
  27. containsMoreThanOneSlashInNationalNumber(number, '49/69/2013').should.equal(true)
  28. })
  29. })
  30. */
  31. //# sourceMappingURL=Leniency.test.js.map