Exemplo n.º 1
0
  it('should validate an Australian phone number', function(){

    // Using the split method above
    var val1 = "024999 6677 string";
    var val2 = "uity( )+0400222345";
    var val3 = "61 24st ring";
    methods.australianPhoneNumber(methods.splitNumber(val1)).should.be.true;
    methods.australianPhoneNumber(methods.splitNumber(val2)).should.be.true;
    methods.australianPhoneNumber(methods.splitNumber(val3)).should.be.false;

    // validate 49997878
    methods.australianPhoneNumber('39996677').should.be.true;
    methods.australianPhoneNumber('19996677').should.be.false;
    methods.australianPhoneNumber('29996677').should.be.false;
    methods.australianPhoneNumber('3999667').should.be.false;
    methods.australianPhoneNumber('399966777').should.be.false;
    methods.australianPhoneNumber('3w996677').should.be.false;

    // validate 0249997878
    methods.australianPhoneNumber('0249996677').should.be.true;
    methods.australianPhoneNumber('024999667').should.be.false;
    methods.australianPhoneNumber('02499966777').should.be.false;
    methods.australianPhoneNumber('0219996677').should.be.false;
    methods.australianPhoneNumber('0229996677').should.be.false;
    methods.australianPhoneNumber('1219996677').should.be.false;
    methods.australianPhoneNumber('4229996677').should.be.false;
    methods.australianPhoneNumber('02w9996677').should.be.false;

    // validate 61249997878 (landline with Country Code)
    methods.australianPhoneNumber('61249996677').should.be.true;
    methods.australianPhoneNumber('6124999667').should.be.false;
    methods.australianPhoneNumber('612499966777').should.be.false;
    methods.australianPhoneNumber('62249996677').should.be.false;
    methods.australianPhoneNumber('71249996677').should.be.false;
    methods.australianPhoneNumber('6124999w677').should.be.false;

    // validate 0422999787
    methods.australianPhoneNumber('0400222345').should.be.true;
    methods.australianPhoneNumber('040022234').should.be.false;
    methods.australianPhoneNumber('04002223444').should.be.false;
    methods.australianPhoneNumber('1400222345').should.be.false;
    methods.australianPhoneNumber('0400w22345').should.be.false;

    // validate 61422999787 (mobile with Country Code)
    methods.australianPhoneNumber('61422999787').should.be.true;
    methods.australianPhoneNumber('6140022234').should.be.false;
    methods.australianPhoneNumber('614002223444').should.be.false;
    methods.australianPhoneNumber('61400w22345').should.be.false;

    chai.assert.isUndefined(methods.australianPhoneNumber(''));
    chai.assert.isUndefined(methods.australianPhoneNumber(null));
    chai.assert.isUndefined(methods.australianPhoneNumber(undefined));
  });
Exemplo n.º 2
0
 it('should remove digits from a string', function(){
   methods.splitNumber('+61-555-555-555').should.equal('61555555555');
   methods.splitNumber('61 555 555 555').should.be.equal('61555555555');
   methods.splitNumber('(*>_61 555-+=555 555\}{}~').should.be.equal('61555555555');
   methods.splitNumber('eggplant').should.be.equal("");
 });