Sha256: ceffb1b38b900dc15ecf433a6f90dd216d70f8bbe8b1657a45b83f9a98d33f18

Contents?: true

Size: 1.99 KB

Versions: 52

Compression:

Stored size: 1.99 KB

Contents

var PhoneNumber = require('./phone-number');

describe('PhoneNumber()', function() {
  it('cleans the number', function() {
    var phone = new PhoneNumber('(223) 456-7890');
    expect(phone.number()).toEqual('2234567890');
  });

  xit('cleans numbers with dots', function() {
    var phone = new PhoneNumber('223.456.7890');
    expect(phone.number()).toEqual('2234567890');
  });

  xit('cleans numbers with multiple spaces', function() {
    var phone = new PhoneNumber('223 456   7890   ');
    expect(phone.number()).toEqual('2234567890');
  });
  
  xit('invalid when 9 digits', function() {
    var phone = new PhoneNumber('123456789');
    expect(phone.number()).toEqual(null);
  });
  
  xit('invalid when 11 digits does not start with a 1', function(){
    var phone = new PhoneNumber('22234567890'); 
    expect(phone.number()).toEqual(null); 
  }); 
  
  xit('valid when 11 digits and starting with 1', function(){
    var phone = new PhoneNumber('12234567890'); 
    expect(phone.number()).toEqual('2234567890'); 
  }); 
  
  xit('valid when 11 digits and starting with 1 even with punctuation', function(){
    var phone = new PhoneNumber('+1 (223) 456-7890'); 
    expect(phone.number()).toEqual('2234567890'); 
  }); 
  
  xit('invalid when more than 11 digits', function(){
    var phone = new PhoneNumber('321234567890'); 
    expect(phone.number()).toEqual(null); 
  }); 
  
  xit('invalid with letters', function(){
    var phone = new PhoneNumber('123-abc-7890'); 
    expect(phone.number()).toEqual(null); 
  }); 
  
  xit('invalid with punctuations', function(){
    var phone = new PhoneNumber('123-@:!-7890'); 
    expect(phone.number()).toEqual(null); 
  }); 
  
  xit('invalid if area code does not start with 2-9', function(){
    var phone = new PhoneNumber('(123) 456-7890'); 
    expect(phone.number()).toEqual(null); 
  }); 
  
  xit('invalid if exchange code does not start with 2-9', function(){
    var phone = new PhoneNumber('(223) 056-7890'); 
    expect(phone.number()).toEqual(null); 
  }); 
});

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
trackler-2.2.1.37 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.36 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.35 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.34 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.33 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.32 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.31 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.30 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.29 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.28 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.27 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.26 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.25 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.24 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.23 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.22 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.21 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.20 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.19 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.18 tracks/javascript/exercises/phone-number/phone-number.spec.js