Sha256: b0f29bb7e14c57f176bee580144d393eb814b6a1b024e55bfee534afc0bb6fda

Contents?: true

Size: 1.97 KB

Versions: 141

Compression:

Stored size: 1.97 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

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.158 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.157 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.156 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.155 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.154 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.153 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.152 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.151 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.150 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.149 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.148 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.147 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.146 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.145 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.144 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.143 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.142 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.141 tracks/javascript/exercises/phone-number/phone-number.spec.js
trackler-2.2.1.140 tracks/javascript/exercises/phone-number/phone-number.spec.js